From 5783caf68e3399772eb90c628a63cbe4050aa30e Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sat, 21 Jun 2025 17:06:09 -0600 Subject: [PATCH] CMake: Add windows vcpkg triplet files to minimize port builds Now we won't be building both debug and release for all ports when using a release, distribution, or sanitizer preset. Eventually we can use this to build all our ports with clang-cl.exe. That doesn't work at all out of the box, and needs a bunch of extra legwork. Likely legwork for every port we build. --- Meta/CMake/vcpkg/base-triplets/x64-windows.cmake | 4 ++++ Meta/CMake/vcpkg/debug-triplets/x64-windows.cmake | 2 ++ .../distribution-triplets/x64-windows-static.cmake | 3 +++ .../vcpkg/generate_vcpkg_toolchain_variables.cmake | 13 ++++++++----- Meta/CMake/vcpkg/release-triplets/x64-windows.cmake | 3 +++ Meta/CMake/vcpkg/sanitizer-triplets/sanitizer.cmake | 7 ++++++- .../vcpkg/sanitizer-triplets/x64-windows.cmake | 3 +++ 7 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 Meta/CMake/vcpkg/base-triplets/x64-windows.cmake create mode 100644 Meta/CMake/vcpkg/debug-triplets/x64-windows.cmake create mode 100644 Meta/CMake/vcpkg/distribution-triplets/x64-windows-static.cmake create mode 100644 Meta/CMake/vcpkg/release-triplets/x64-windows.cmake create mode 100644 Meta/CMake/vcpkg/sanitizer-triplets/x64-windows.cmake diff --git a/Meta/CMake/vcpkg/base-triplets/x64-windows.cmake b/Meta/CMake/vcpkg/base-triplets/x64-windows.cmake new file mode 100644 index 00000000000..a6ad1bcabf6 --- /dev/null +++ b/Meta/CMake/vcpkg/base-triplets/x64-windows.cmake @@ -0,0 +1,4 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) + +include(${CMAKE_CURRENT_LIST_DIR}/base.cmake) diff --git a/Meta/CMake/vcpkg/debug-triplets/x64-windows.cmake b/Meta/CMake/vcpkg/debug-triplets/x64-windows.cmake new file mode 100644 index 00000000000..7ea257adf1b --- /dev/null +++ b/Meta/CMake/vcpkg/debug-triplets/x64-windows.cmake @@ -0,0 +1,2 @@ +include (${CMAKE_CURRENT_LIST_DIR}/../base-triplets/x64-windows.cmake) +include (${CMAKE_CURRENT_LIST_DIR}/debug.cmake) diff --git a/Meta/CMake/vcpkg/distribution-triplets/x64-windows-static.cmake b/Meta/CMake/vcpkg/distribution-triplets/x64-windows-static.cmake new file mode 100644 index 00000000000..6ce39b9d6e3 --- /dev/null +++ b/Meta/CMake/vcpkg/distribution-triplets/x64-windows-static.cmake @@ -0,0 +1,3 @@ +# Note: This is equivalent to upstream x64-windows-static-md-release.cmake +include (${CMAKE_CURRENT_LIST_DIR}/../base-triplets/x64-windows.cmake) +include (${CMAKE_CURRENT_LIST_DIR}/distribution.cmake) diff --git a/Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake b/Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake index 88436155b65..1dad1d28760 100644 --- a/Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake +++ b/Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake @@ -1,11 +1,14 @@ # The generated file here is read by vcpkg/base-triplets/base.cmake to ensure consistency between the project # build and the vcpkg build. set(EXTRA_VCPKG_VARIABLES "") -if (NOT "${CMAKE_C_COMPILER}" STREQUAL "") - string(APPEND EXTRA_VCPKG_VARIABLES "set(ENV{CC} ${CMAKE_C_COMPILER})\n") -endif() -if (NOT "${CMAKE_CXX_COMPILER}" STREQUAL "") - string(APPEND EXTRA_VCPKG_VARIABLES "set(ENV{CXX} ${CMAKE_CXX_COMPILER})\n") +if (NOT WIN32) + # Supporting Clang-CL for all our vcpkg ports is an adventure in itself, so let's not + if (NOT "${CMAKE_C_COMPILER}" STREQUAL "") + string(APPEND EXTRA_VCPKG_VARIABLES "set(ENV{CC} ${CMAKE_C_COMPILER})\n") + endif() + if (NOT "${CMAKE_CXX_COMPILER}" STREQUAL "") + string(APPEND EXTRA_VCPKG_VARIABLES "set(ENV{CXX} ${CMAKE_CXX_COMPILER})\n") + endif() endif() # Workaround for bad patchelf interaction with binutils 2.43.50 diff --git a/Meta/CMake/vcpkg/release-triplets/x64-windows.cmake b/Meta/CMake/vcpkg/release-triplets/x64-windows.cmake new file mode 100644 index 00000000000..69fd9ec480a --- /dev/null +++ b/Meta/CMake/vcpkg/release-triplets/x64-windows.cmake @@ -0,0 +1,3 @@ +# Note: This is equivalent to upstream x64-windows-release.cmake +include (${CMAKE_CURRENT_LIST_DIR}/../base-triplets/x64-windows.cmake) +include (${CMAKE_CURRENT_LIST_DIR}/release.cmake) diff --git a/Meta/CMake/vcpkg/sanitizer-triplets/sanitizer.cmake b/Meta/CMake/vcpkg/sanitizer-triplets/sanitizer.cmake index c8ad8738c4b..7b546d464f5 100644 --- a/Meta/CMake/vcpkg/sanitizer-triplets/sanitizer.cmake +++ b/Meta/CMake/vcpkg/sanitizer-triplets/sanitizer.cmake @@ -2,4 +2,9 @@ set(VCPKG_BUILD_TYPE release) set(VCPKG_LIBRARY_LINKAGE dynamic) set(VCPKG_C_FLAGS "") -set(VCPKG_CXX_FLAGS "-frtti") + +if (WIN32) + set(VCPKG_CXX_FLAGS "/GR") +else() + set(VCPKG_CXX_FLAGS "-frtti") +endif() diff --git a/Meta/CMake/vcpkg/sanitizer-triplets/x64-windows.cmake b/Meta/CMake/vcpkg/sanitizer-triplets/x64-windows.cmake new file mode 100644 index 00000000000..993a440e131 --- /dev/null +++ b/Meta/CMake/vcpkg/sanitizer-triplets/x64-windows.cmake @@ -0,0 +1,3 @@ +# Note: This is mostly equivalent to upstream x64-windows-release.cmake +include (${CMAKE_CURRENT_LIST_DIR}/../base-triplets/x64-windows.cmake) +include (${CMAKE_CURRENT_LIST_DIR}/sanitizer.cmake)