diff --git a/CMakePresets.json b/CMakePresets.json index fd4cd0a..4dc1dbd 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -7,7 +7,7 @@ "generator": "Ninja", "cacheVariables": { "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", - "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake", + "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/cmake/vcpkg_toolchain_wrapper.cmake", "VCPKG_FEATURE_FLAGS": "manifests", "QUARK_ENABLE_ASAN": "OFF", "QUARK_ENABLE_UBSAN": "OFF", @@ -15,7 +15,6 @@ "QUARK_ENABLE_LTO": "OFF" } }, - { "name": "macos-arm64", "hidden": true, @@ -67,12 +66,13 @@ "VCPKG_HOST_TRIPLET": "x64-windows" } }, - { "name": "macos-arm64-debug", "inherits": "macos-arm64", "binaryDir": "${sourceDir}/build/macos-arm64-debug", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } }, { "name": "macos-x64-debug", @@ -96,7 +96,9 @@ "name": "macos-arm64-release", "inherits": "macos-arm64", "binaryDir": "${sourceDir}/build/macos-arm64-release", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } }, { "name": "macos-arm64-release-lto", @@ -107,12 +109,13 @@ "QUARK_ENABLE_LTO": "ON" } }, - { "name": "linux-x64-gcc-debug", "inherits": "linux-x64-gcc", "binaryDir": "${sourceDir}/build/linux-x64-gcc-debug", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } }, { "name": "linux-x64-gcc-asan-ubsan", @@ -137,7 +140,9 @@ "name": "linux-x64-gcc-release", "inherits": "linux-x64-gcc", "binaryDir": "${sourceDir}/build/linux-x64-gcc-release", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } }, { "name": "linux-x64-gcc-release-lto", @@ -148,12 +153,13 @@ "QUARK_ENABLE_LTO": "ON" } }, - { "name": "linux-x64-clang-debug", "inherits": "linux-x64-clang", "binaryDir": "${sourceDir}/build/linux-x64-clang-debug", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } }, { "name": "linux-x64-clang-asan-ubsan", @@ -178,7 +184,9 @@ "name": "linux-x64-clang-release", "inherits": "linux-x64-clang", "binaryDir": "${sourceDir}/build/linux-x64-clang-release", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } }, { "name": "linux-x64-clang-release-lto", @@ -189,18 +197,21 @@ "QUARK_ENABLE_LTO": "ON" } }, - { "name": "windows-x64-msvc-debug", "inherits": "windows-x64-msvc", "binaryDir": "${sourceDir}/build/windows-x64-msvc-debug", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } }, { "name": "windows-x64-msvc-release", "inherits": "windows-x64-msvc", "binaryDir": "${sourceDir}/build/windows-x64-msvc-release", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } }, { "name": "windows-x64-msvc-release-lto", @@ -212,7 +223,6 @@ } } ], - "buildPresets": [ { "name": "macos-arm64-debug", @@ -230,12 +240,10 @@ "name": "macos-arm64-release-lto", "configurePreset": "macos-arm64-release-lto" }, - { "name": "macos-x64-debug", "configurePreset": "macos-x64-debug" }, - { "name": "linux-x64-gcc-debug", "configurePreset": "linux-x64-gcc-debug" @@ -256,7 +264,6 @@ "name": "linux-x64-gcc-release-lto", "configurePreset": "linux-x64-gcc-release-lto" }, - { "name": "linux-x64-clang-debug", "configurePreset": "linux-x64-clang-debug" @@ -277,7 +284,6 @@ "name": "linux-x64-clang-release-lto", "configurePreset": "linux-x64-clang-release-lto" }, - { "name": "windows-x64-msvc-debug", "configurePreset": "windows-x64-msvc-debug" @@ -291,4 +297,4 @@ "configurePreset": "windows-x64-msvc-release-lto" } ] -} +} \ No newline at end of file diff --git a/cmake/preflight_submodules.cmake b/cmake/preflight_submodules.cmake new file mode 100644 index 0000000..bb3cc66 --- /dev/null +++ b/cmake/preflight_submodules.cmake @@ -0,0 +1 @@ +message(STATUS "[quark] preflight include active") diff --git a/cmake/vcpkg_toolchain_wrapper.cmake b/cmake/vcpkg_toolchain_wrapper.cmake new file mode 100644 index 0000000..2339448 --- /dev/null +++ b/cmake/vcpkg_toolchain_wrapper.cmake @@ -0,0 +1,50 @@ +get_filename_component(QUARK_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) +set(QUARK_VCPKG_ROOT "${QUARK_SOURCE_DIR}/vcpkg") + +if(EXISTS "${QUARK_SOURCE_DIR}/.gitmodules") + find_program(QUARK_GIT_EXECUTABLE git) + if(QUARK_GIT_EXECUTABLE) + execute_process( + COMMAND "${QUARK_GIT_EXECUTABLE}" submodule update --init --recursive --force + WORKING_DIRECTORY "${QUARK_SOURCE_DIR}" + RESULT_VARIABLE quark_submodule_result + OUTPUT_QUIET + ERROR_QUIET + ) + + if(NOT quark_submodule_result EQUAL 0) + message(WARNING "Unable to auto-update git submodules. Run 'git submodule update --init --recursive'.") + endif() + + if(EXISTS "${QUARK_VCPKG_ROOT}/.git") + foreach(quark_bootstrap_file bootstrap-vcpkg.sh bootstrap-vcpkg.bat) + if(NOT EXISTS "${QUARK_VCPKG_ROOT}/${quark_bootstrap_file}") + execute_process( + COMMAND "${QUARK_GIT_EXECUTABLE}" -C "${QUARK_VCPKG_ROOT}" restore -- "${quark_bootstrap_file}" + RESULT_VARIABLE quark_restore_result + OUTPUT_QUIET + ERROR_QUIET + ) + + if(NOT quark_restore_result EQUAL 0) + message(WARNING "Unable to restore ${quark_bootstrap_file} in vcpkg submodule.") + endif() + endif() + endforeach() + endif() + endif() +endif() + +if(UNIX AND EXISTS "${QUARK_VCPKG_ROOT}/bootstrap-vcpkg.sh") + execute_process( + COMMAND chmod +x "${QUARK_VCPKG_ROOT}/bootstrap-vcpkg.sh" + OUTPUT_QUIET + ERROR_QUIET + ) +endif() + +if(NOT EXISTS "${QUARK_VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") + message(FATAL_ERROR "Missing vcpkg toolchain file at ${QUARK_VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") +endif() + +include("${QUARK_VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")