|
1 | 1 | ################# Initialize Common Variables ################### |
2 | 2 | if(NOT DEFINED ENV{VCPKG_ROOT}) |
3 | | - set(VCPKG_ROOT "${CMAKE_BINARY_DIR}/vcpkg" CACHE PATH "VCPKG Root") |
4 | | - if(NOT EXISTS "${VCPKG_ROOT}") |
5 | | - message(STATUS "Bootstrapping vcpkg...") |
6 | | - execute_process( |
7 | | - COMMAND git clone https://github.com/microsoft/vcpkg.git "${VCPKG_ROOT}" |
8 | | - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" |
9 | | - ) |
10 | | - if(WIN32) |
11 | | - execute_process(COMMAND "${VCPKG_ROOT}/bootstrap-vcpkg.bat") |
12 | | - else() |
13 | | - execute_process(COMMAND "${VCPKG_ROOT}/bootstrap-vcpkg.sh") |
14 | | - endif() |
| 3 | + set(VCPKG_ROOT "${CMAKE_BINARY_DIR}/vcpkg" CACHE PATH "VCPKG Root") |
| 4 | + if(NOT EXISTS "${VCPKG_ROOT}") |
| 5 | + message(STATUS "Bootstrapping vcpkg...") |
| 6 | + if (GIT_IN_USE) |
| 7 | + execute_process( |
| 8 | + COMMAND git clone https://github.com/microsoft/vcpkg.git "${VCPKG_ROOT}" |
| 9 | + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") |
| 10 | + else() |
| 11 | + set(VCPKG_MANIFEST_MODE OFF CACHE BOOL "Disable vcpkg manifest mode" FORCE) |
| 12 | + set(VCPKG_ZIP_FILE "${CMAKE_BINARY_DIR}/vcpkg.zip") |
| 13 | + set(VCPKG_EXTRACT_DEST "${CMAKE_BINARY_DIR}/vcpkg-extracted-temp") |
| 14 | + |
| 15 | + # Use file(DOWNLOAD) to fetch the source archive |
| 16 | + if(NOT EXISTS "${VCPKG_ZIP_FILE}") |
| 17 | + message(STATUS "Downloading vcpkg source archive...") |
| 18 | + file(DOWNLOAD "https://github.com/microsoft/vcpkg/archive/refs/heads/master.zip" "${VCPKG_ZIP_FILE}" |
| 19 | + SHOW_PROGRESS) |
| 20 | + message(STATUS "Downloading vcpkg source archive... done") |
| 21 | + endif() |
| 22 | + |
| 23 | + # Use file(ARCHIVE_EXTRACT) to unzip the source |
| 24 | + if(NOT EXISTS "${VCPKG_EXTRACT_DEST}") |
| 25 | + message(STATUS "Extracting vcpkg archive...") |
| 26 | + file(ARCHIVE_EXTRACT INPUT "${VCPKG_ZIP_FILE}" DESTINATION "${VCPKG_EXTRACT_DEST}" ) |
| 27 | + |
| 28 | + # Move the extracted content (which is in a directory like vcpkg-master) |
| 29 | + # to the desired VCPKG_ROOT path defined in your original script. |
| 30 | + file(GLOB VCPKG_SOURCE_DIR_TMP "${VCPKG_EXTRACT_DEST}/vcpkg-*") |
| 31 | + file(RENAME "${VCPKG_SOURCE_DIR_TMP}" "${VCPKG_ROOT}") |
| 32 | + message(STATUS "Extracting vcpkg archive... done") |
| 33 | + endif() |
| 34 | + endif() |
| 35 | + if(WIN32) |
| 36 | + execute_process(COMMAND "${VCPKG_ROOT}/bootstrap-vcpkg.bat") |
| 37 | + else() |
| 38 | + execute_process(COMMAND "${VCPKG_ROOT}/bootstrap-vcpkg.sh") |
| 39 | + endif() |
15 | 40 | endif() |
16 | 41 | else() |
17 | 42 | file(TO_CMAKE_PATH $ENV{VCPKG_ROOT} VCPKG_ROOT) |
@@ -52,7 +77,16 @@ set(ENV{VCPKG_KEEP_ENV_VARS} "VCPKG_LIB_SOURCE_ROOT") |
52 | 77 | # All include directories to search. Modules should append to this when they want includes to point |
53 | 78 | # into themselves. |
54 | 79 | set(TORQUE_INCLUDE_DIRECTORIES "") |
55 | | - |
| 80 | +if (NOT GIT_IN_USE) |
| 81 | + execute_process( |
| 82 | + COMMAND vcpkg install |
| 83 | + --classic |
| 84 | + --triplet=${VCPKG_TARGET_TRIPLET} |
| 85 | + --overlay-ports=${VCPKG_OVERLAY_PORTS} |
| 86 | + --overlay-triplets=${VCPKG_OVERLAY_TRIPLETS} |
| 87 | + libflac libogg libsndfile[external-libs] libtheora libvorbis opus |
| 88 | + WORKING_DIRECTORY ${VCPKG_ROOT}) |
| 89 | +endif() |
56 | 90 | # All library binaries to install. Modules should append to this the path of any library binaries (.so, .dylib, .dll) |
57 | 91 | # that should be installed next to the executable. |
58 | 92 | set(TORQUE_ADDITIONAL_LIBRARY_BINARIES "") |
|
0 commit comments