use FetchContent instead
This commit is contained in:
parent
eaf61585ea
commit
c3440d7eba
1 changed files with 18 additions and 22 deletions
|
@ -1,29 +1,25 @@
|
||||||
cmake_minimum_required(VERSION 3.17)
|
cmake_minimum_required(VERSION 3.17)
|
||||||
|
|
||||||
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchain.cmake")
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(
|
||||||
|
vcpkg
|
||||||
|
GIT_REPOSITORY https://github.com/microsoft/vcpkg
|
||||||
|
GIT_TAG 1257354a3ab0bebd8abe95281ca561537853578c
|
||||||
|
)
|
||||||
|
|
||||||
find_package(Git QUIET)
|
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||||
if (GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
FetchContent_GetProperties(vcpkg
|
||||||
# Update submodules as needed
|
POPULATED vcpkg_POPULATED
|
||||||
option(GIT_SUBMODULE "Check submodules during build" ON)
|
SOURCE_DIR vcpkg_SOURCE_DIR)
|
||||||
if (GIT_SUBMODULE)
|
if(NOT vcpkg_POPULATED)
|
||||||
message(STATUS "Submodule update")
|
FetchContent_Populate(vcpkg)
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
|
endif()
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
||||||
RESULT_VARIABLE GIT_SUBMOD_RESULT)
|
|
||||||
if (NOT GIT_SUBMOD_RESULT EQUAL "0")
|
|
||||||
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/LICENSE.txt")
|
set(CMAKE_TOOLCHAIN_FILE
|
||||||
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
|
"${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake")
|
||||||
endif ()
|
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchain.cmake")
|
||||||
#This needs to be set before project()
|
endif()
|
||||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake
|
|
||||||
CACHE STRING "Vcpkg toolchain file")
|
|
||||||
|
|
||||||
enable_language(CXX)
|
enable_language(CXX)
|
||||||
project(pacman)
|
project(pacman)
|
||||||
|
|
Loading…
Reference in a new issue