Merge pull request #1628 from Azaezel/alpha41/gitAsOption

git as option
This commit is contained in:
Brian Roberts 2025-12-21 22:59:25 -06:00 committed by GitHub
commit 4c7e445615
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 61 additions and 21 deletions

View file

@ -2,12 +2,12 @@ cmake_minimum_required (VERSION 3.21.0)
set (CMAKE_CXX_STANDARD 17)
set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo;Release" CACHE STRING "" FORCE)
include("${CMAKE_SOURCE_DIR}/Tools/CMake/torque_macros.cmake")
include("${CMAKE_SOURCE_DIR}/Tools/CMake/torque_configs.cmake")
# Ensure multi-core compilation is enabled for everything
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
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")
@ -15,6 +15,13 @@ 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")
# Ensure multi-core compilation is enabled for everything
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
project(${TORQUE_APP_NAME})
# Once an app name is determined, we know what our project pathing structure should look like

View file

@ -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 "")

View file

@ -17,8 +17,7 @@
}
],
"default-features": [
"external-libs",
"mpeg"
"external-libs"
],
"features": {
"experimental": {