From 21eb82227674604f78386dc37db6eb298707e4f5 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Mon, 30 Jun 2025 13:40:18 -0700 Subject: [PATCH 1/2] Fix build problem when multiple VS toolsets are installed --- docs/src/developer_guide/compiling.rst | 3 +++ .../x64-windows-static-md-fix.cmake | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/docs/src/developer_guide/compiling.rst b/docs/src/developer_guide/compiling.rst index a5e24a5eb..ea8af00f3 100644 --- a/docs/src/developer_guide/compiling.rst +++ b/docs/src/developer_guide/compiling.rst @@ -250,6 +250,9 @@ The following table lists the available configuration options: * - ``SGL_ENABLE_HEADER_VALIDATION`` - ``OFF`` - Enable header validation + * - ``SGL_MSVC_TOOLSET_VERSION`` + - ``Unset`` + - Specify an exact MSVC toolset version to use (e.g., `14.38.33130`) diff --git a/external/vcpkg-triplets/x64-windows-static-md-fix.cmake b/external/vcpkg-triplets/x64-windows-static-md-fix.cmake index ee2c7d283..f6d946088 100644 --- a/external/vcpkg-triplets/x64-windows-static-md-fix.cmake +++ b/external/vcpkg-triplets/x64-windows-static-md-fix.cmake @@ -1,3 +1,25 @@ +# Allow user to explicitly specify a toolset version via -DSGL_MSVC_TOOLSET_VERSION=... +# If not specified, it falls back to the VCToolsVersion from the developer environment. +if(DEFINED SGL_MSVC_TOOLSET_VERSION) + set(toolset_to_use ${SGL_MSVC_TOOLSET_VERSION}) + message(STATUS "Triplet: Using user-specified toolset version '${toolset_to_use}'.") +elseif(DEFINED ENV{VCToolsVersion}) + set(toolset_to_use "$ENV{VCToolsVersion}") + message(STATUS "Triplet: Using toolset version from environment: '${toolset_to_use}'.") +endif() + +if(DEFINED toolset_to_use) + # Set the detailed toolset version. This forces vcpkg to use the specific toolset. + set(VCPKG_PLATFORM_TOOLSET_VERSION "${toolset_to_use}") + + # Also set the major toolset version, as vcpkg may require it to be present. + string(REGEX MATCH "^([0-9]+)\\.([0-9])" _match "${toolset_to_use}") + if(_match) + set(derived_toolset "v${CMAKE_MATCH_1}${CMAKE_MATCH_2}") + set(VCPKG_PLATFORM_TOOLSET "${derived_toolset}") + endif() +endif() + set(VCPKG_TARGET_ARCHITECTURE x64) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE static) From ee4f087257abdbb2c0a9e9d3f0287e598ea28348 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Wed, 15 Oct 2025 16:11:38 -0700 Subject: [PATCH 2/2] Fix vcpkg triplet to correctly map MSVC 14.4X to v143 toolset The previous code incorrectly derived platform toolset "v144" from MSVC toolset version 14.44+, but v144 does not exist. All VS 2022 versions (including 14.3X and 14.4X) use the v143 platform toolset. This fix properly maps toolset versions to their corresponding platform toolsets: - 14.0X -> v140 (VS 2015) - 14.1X -> v141 (VS 2017) - 14.2X -> v142 (VS 2019) - 14.3X-14.4X -> v143 (VS 2022) Reference: https://devblogs.microsoft.com/cppblog/msvc-toolset-minor-version-number-14-40-in-vs-2022-v17-10/ > The C++ Project System (MS Build) is being updated to support '14.4x' MSVC toolsets under the v143 Platform Toolset. --- docs/src/developer_guide/compiling.rst | 2 +- .../x64-windows-static-md-fix.cmake | 25 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/docs/src/developer_guide/compiling.rst b/docs/src/developer_guide/compiling.rst index ea8af00f3..5f4284878 100644 --- a/docs/src/developer_guide/compiling.rst +++ b/docs/src/developer_guide/compiling.rst @@ -252,7 +252,7 @@ The following table lists the available configuration options: - Enable header validation * - ``SGL_MSVC_TOOLSET_VERSION`` - ``Unset`` - - Specify an exact MSVC toolset version to use (e.g., `14.38.33130`) + - Specify an exact MSVC toolset version to use (e.g., `14.44.35207`) diff --git a/external/vcpkg-triplets/x64-windows-static-md-fix.cmake b/external/vcpkg-triplets/x64-windows-static-md-fix.cmake index f6d946088..822456bb7 100644 --- a/external/vcpkg-triplets/x64-windows-static-md-fix.cmake +++ b/external/vcpkg-triplets/x64-windows-static-md-fix.cmake @@ -13,9 +13,30 @@ if(DEFINED toolset_to_use) set(VCPKG_PLATFORM_TOOLSET_VERSION "${toolset_to_use}") # Also set the major toolset version, as vcpkg may require it to be present. - string(REGEX MATCH "^([0-9]+)\\.([0-9])" _match "${toolset_to_use}") + # For VS 2022, all versions (14.30-14.49) use v143 toolset + string(REGEX MATCH "^([0-9]+)\\.([0-9]+)" _match "${toolset_to_use}") if(_match) - set(derived_toolset "v${CMAKE_MATCH_1}${CMAKE_MATCH_2}") + # Map version to correct Visual Studio toolset + # 14.0-14.9 -> v140 (VS 2015) + # 14.1X -> v141 (VS 2017) + # 14.2X -> v142 (VS 2019) + # 14.3X-14.4X -> v143 (VS 2022) + if(CMAKE_MATCH_1 EQUAL 14) + if(CMAKE_MATCH_2 GREATER_EQUAL 0 AND CMAKE_MATCH_2 LESS 10) + set(derived_toolset "v140") + elseif(CMAKE_MATCH_2 GREATER_EQUAL 10 AND CMAKE_MATCH_2 LESS 20) + set(derived_toolset "v141") + elseif(CMAKE_MATCH_2 GREATER_EQUAL 20 AND CMAKE_MATCH_2 LESS 30) + set(derived_toolset "v142") + else() + # v143 for 14.30+ (VS 2022 and future versions) + # Covers 14.3X, 14.4X, and beyond + set(derived_toolset "v143") + endif() + else() + # Fallback for unknown versions + set(derived_toolset "v${CMAKE_MATCH_1}${CMAKE_MATCH_2}") + endif() set(VCPKG_PLATFORM_TOOLSET "${derived_toolset}") endif() endif()