diff --git a/CMakeLists.txt b/CMakeLists.txt index f7ae4dc32..07a14c6fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,20 @@ cmake_minimum_required (VERSION 3.21.0) set (CMAKE_CXX_STANDARD 17) set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo;Release" CACHE STRING "" FORCE) +find_program(GIT_EXECUTABLE git) +if(GIT_EXECUTABLE) + option(GIT_IN_USE "use Git" ON) +else() + option(GIT_IN_USE "use Git" OFF) +endif() + # An application name must be set first set(TORQUE_APP_NAME "" CACHE STRING "the app name") if("${TORQUE_APP_NAME}" STREQUAL "") message(FATAL_ERROR "Please set TORQUE_APP_NAME first") endif() + include("${CMAKE_SOURCE_DIR}/Tools/CMake/torque_macros.cmake") include("${CMAKE_SOURCE_DIR}/Tools/CMake/torque_configs.cmake") diff --git a/Tools/CMake/torque_configs.cmake b/Tools/CMake/torque_configs.cmake index 9c3b158df..39fe01e1d 100644 --- a/Tools/CMake/torque_configs.cmake +++ b/Tools/CMake/torque_configs.cmake @@ -1,17 +1,42 @@ ################# Initialize Common Variables ################### if(NOT DEFINED ENV{VCPKG_ROOT}) - set(VCPKG_ROOT "${CMAKE_BINARY_DIR}/vcpkg" CACHE PATH "VCPKG Root") - if(NOT EXISTS "${VCPKG_ROOT}") - message(STATUS "Bootstrapping vcpkg...") - execute_process( - COMMAND git clone https://github.com/microsoft/vcpkg.git "${VCPKG_ROOT}" - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - ) - if(WIN32) - execute_process(COMMAND "${VCPKG_ROOT}/bootstrap-vcpkg.bat") - else() - execute_process(COMMAND "${VCPKG_ROOT}/bootstrap-vcpkg.sh") - endif() + set(VCPKG_ROOT "${CMAKE_BINARY_DIR}/vcpkg" CACHE PATH "VCPKG Root") + if(NOT EXISTS "${VCPKG_ROOT}") + message(STATUS "Bootstrapping vcpkg...") + if (GIT_IN_USE) + execute_process( + COMMAND git clone https://github.com/microsoft/vcpkg.git "${VCPKG_ROOT}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") + else() + set(VCPKG_MANIFEST_MODE OFF CACHE BOOL "Disable vcpkg manifest mode" FORCE) + set(VCPKG_ZIP_FILE "${CMAKE_BINARY_DIR}/vcpkg.zip") + set(VCPKG_EXTRACT_DEST "${CMAKE_BINARY_DIR}/vcpkg-extracted-temp") + + # Use file(DOWNLOAD) to fetch the source archive + if(NOT EXISTS "${VCPKG_ZIP_FILE}") + message(STATUS "Downloading vcpkg source archive...") + file(DOWNLOAD "https://github.com/microsoft/vcpkg/archive/refs/heads/master.zip" "${VCPKG_ZIP_FILE}" + SHOW_PROGRESS) + message(STATUS "Downloading vcpkg source archive... done") + endif() + + # Use file(ARCHIVE_EXTRACT) to unzip the source + if(NOT EXISTS "${VCPKG_EXTRACT_DEST}") + message(STATUS "Extracting vcpkg archive...") + file(ARCHIVE_EXTRACT INPUT "${VCPKG_ZIP_FILE}" DESTINATION "${VCPKG_EXTRACT_DEST}" ) + + # Move the extracted content (which is in a directory like vcpkg-master) + # to the desired VCPKG_ROOT path defined in your original script. + file(GLOB VCPKG_SOURCE_DIR_TMP "${VCPKG_EXTRACT_DEST}/vcpkg-*") + file(RENAME "${VCPKG_SOURCE_DIR_TMP}" "${VCPKG_ROOT}") + message(STATUS "Extracting vcpkg archive... done") + endif() + endif() + if(WIN32) + execute_process(COMMAND "${VCPKG_ROOT}/bootstrap-vcpkg.bat") + else() + execute_process(COMMAND "${VCPKG_ROOT}/bootstrap-vcpkg.sh") + endif() endif() else() file(TO_CMAKE_PATH $ENV{VCPKG_ROOT} VCPKG_ROOT) @@ -52,7 +77,16 @@ set(ENV{VCPKG_KEEP_ENV_VARS} "VCPKG_LIB_SOURCE_ROOT") # All include directories to search. Modules should append to this when they want includes to point # into themselves. set(TORQUE_INCLUDE_DIRECTORIES "") - +if (NOT GIT_IN_USE) + execute_process( + COMMAND vcpkg install + --classic + --triplet=${VCPKG_TARGET_TRIPLET} + --overlay-ports=${VCPKG_OVERLAY_PORTS} + --overlay-triplets=${VCPKG_OVERLAY_TRIPLETS} + libflac libogg libsndfile[external-libs] libtheora libvorbis opus + WORKING_DIRECTORY ${VCPKG_ROOT}) +endif() # All library binaries to install. Modules should append to this the path of any library binaries (.so, .dylib, .dll) # that should be installed next to the executable. set(TORQUE_ADDITIONAL_LIBRARY_BINARIES "") diff --git a/Tools/CMake/vcpkg/ports/libsndfile/vcpkg.json b/Tools/CMake/vcpkg/ports/libsndfile/vcpkg.json index 232a349d0..b30913210 100644 --- a/Tools/CMake/vcpkg/ports/libsndfile/vcpkg.json +++ b/Tools/CMake/vcpkg/ports/libsndfile/vcpkg.json @@ -17,8 +17,7 @@ } ], "default-features": [ - "external-libs", - "mpeg" + "external-libs" ], "features": { "experimental": { diff --git a/vcpkg.json b/vcpkg.json deleted file mode 100644 index eb5e7ae38..000000000 --- a/vcpkg.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "torque3d", - "builtin-baseline": "74e6536215718009aae747d86d84b78376bf9e09", - "dependencies": [ - "libogg", - "libvorbis", - "libflac", - "opus", - "libtheora", - { - "name": "libsndfile", - "default-features": false, - "features": [ "external-libs" ] - } - ], - "overrides":[ - { "name": "libogg", "version": "1.3.6"}, - { "name": "libvorbis", "version": "1.3.7"}, - { "name": "libflac", "version": "1.5.0"}, - { "name": "opus", "version": "1.5.2"}, - { "name": "libtheora", "version": "1.2.0"} - ] -} \ No newline at end of file