Skip to content

Commit 4c7e445

Browse files
authored
Merge pull request #1628 from Azaezel/alpha41/gitAsOption
git as option
2 parents 1f5a426 + be8cd10 commit 4c7e445

File tree

3 files changed

+61
-21
lines changed

3 files changed

+61
-21
lines changed

CMakeLists.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@ cmake_minimum_required (VERSION 3.21.0)
22
set (CMAKE_CXX_STANDARD 17)
33
set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo;Release" CACHE STRING "" FORCE)
44

5-
include("${CMAKE_SOURCE_DIR}/Tools/CMake/torque_macros.cmake")
6-
include("${CMAKE_SOURCE_DIR}/Tools/CMake/torque_configs.cmake")
7-
8-
# Ensure multi-core compilation is enabled for everything
9-
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
10-
5+
find_program(GIT_EXECUTABLE git)
6+
if(GIT_EXECUTABLE)
7+
option(GIT_IN_USE "use Git" ON)
8+
else()
9+
option(GIT_IN_USE "use Git" OFF)
10+
endif()
1111

1212
# An application name must be set first
1313
set(TORQUE_APP_NAME "" CACHE STRING "the app name")
1414
if("${TORQUE_APP_NAME}" STREQUAL "")
1515
message(FATAL_ERROR "Please set TORQUE_APP_NAME first")
1616
endif()
1717

18+
19+
include("${CMAKE_SOURCE_DIR}/Tools/CMake/torque_macros.cmake")
20+
include("${CMAKE_SOURCE_DIR}/Tools/CMake/torque_configs.cmake")
21+
22+
# Ensure multi-core compilation is enabled for everything
23+
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
24+
1825
project(${TORQUE_APP_NAME})
1926

2027
# Once an app name is determined, we know what our project pathing structure should look like

Tools/CMake/torque_configs.cmake

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,42 @@
11
################# Initialize Common Variables ###################
22
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()
1540
endif()
1641
else()
1742
file(TO_CMAKE_PATH $ENV{VCPKG_ROOT} VCPKG_ROOT)
@@ -52,7 +77,16 @@ set(ENV{VCPKG_KEEP_ENV_VARS} "VCPKG_LIB_SOURCE_ROOT")
5277
# All include directories to search. Modules should append to this when they want includes to point
5378
# into themselves.
5479
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()
5690
# All library binaries to install. Modules should append to this the path of any library binaries (.so, .dylib, .dll)
5791
# that should be installed next to the executable.
5892
set(TORQUE_ADDITIONAL_LIBRARY_BINARIES "")

Tools/CMake/vcpkg/ports/libsndfile/vcpkg.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
}
1818
],
1919
"default-features": [
20-
"external-libs",
21-
"mpeg"
20+
"external-libs"
2221
],
2322
"features": {
2423
"experimental": {

0 commit comments

Comments
 (0)