From d7bcf6e1f9cc8749dca8cad6317333d55d272601 Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Thu, 11 Sep 2025 08:48:53 -0600 Subject: [PATCH] Win: Preliminary VS 2026 support There is no CMake version yet that support VS2026, support is currently limited to ninja based builds. CMake does not know where to look for the MSVC 2026 Runtime it copies the wrong CRT leading to startup issues, for this reason WITH_WINDOWS_BUNDLE_CRT has been disabled for VS2026 + CMake < 4.2.0. Builds done with VS2026 are for this reason *NOT* distributable to end users at this point in time. CMake 4.2.0 Is *expected* to have VS 2026 support [1] But further testing is likely required. Things of note: - They stopped using the "preview" channel and have rebranded to "Insiders" the make.bat options have been updated accordingly to select the 2026 Insiders build, you need to pass 2026i to make.bat - All tests seem to pass on my system - No new warnings, pretty smooth update [1] https://gitlab.kitware.com/cmake/cmake/-/merge_requests/11168 --- CMakeLists.txt | 7 ++++++- build_files/windows/autodetect_msvc.cmd | 3 +++ build_files/windows/detect_msvc2026.cmd | 3 +++ build_files/windows/parse_arguments.cmd | 8 ++++++++ build_files/windows/show_help.cmd | 3 +++ 5 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 build_files/windows/detect_msvc2026.cmd diff --git a/CMakeLists.txt b/CMakeLists.txt index 68c60ab3a25..54b30068860 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1179,7 +1179,12 @@ if(WIN32) option(WITH_WINDOWS_BUNDLE_CRT "Bundle the C runtime for install free distribution." ON) mark_as_advanced(WITH_WINDOWS_BUNDLE_CRT) - + if(WITH_WINDOWS_BUNDLE_CRT AND + CMAKE_VERSION VERSION_LESS "4.2.0" AND + MSVC_VERSION GREATER_EQUAL 1950) + message(WARNING "VS2026 not supported on this CMAKE version: WITH_WINDOWS_BUNDLE_CRT will be disabled") + set(WITH_WINDOWS_BUNDLE_CRT OFF) + endif() option(WITH_WINDOWS_EXTERNAL_MANIFEST "Use external manifest files" OFF) mark_as_advanced(WITH_WINDOWS_EXTERNAL_MANIFEST) diff --git a/build_files/windows/autodetect_msvc.cmd b/build_files/windows/autodetect_msvc.cmd index fd0c19764e9..a3c80cdcc0d 100644 --- a/build_files/windows/autodetect_msvc.cmd +++ b/build_files/windows/autodetect_msvc.cmd @@ -6,6 +6,9 @@ if %ERRORLEVEL% EQU 0 goto DetectionComplete call "%~dp0\detect_msvc2022.cmd" if %ERRORLEVEL% EQU 0 goto DetectionComplete +call "%~dp0\detect_msvc2026.cmd" +if %ERRORLEVEL% EQU 0 goto DetectionComplete + echo Compiler Detection failed. Use verbose switch for more information. exit /b 1 diff --git a/build_files/windows/detect_msvc2026.cmd b/build_files/windows/detect_msvc2026.cmd new file mode 100644 index 00000000000..80f94c37ab0 --- /dev/null +++ b/build_files/windows/detect_msvc2026.cmd @@ -0,0 +1,3 @@ +set BUILD_VS_VER=18 +set BUILD_VS_YEAR=2026 +call "%~dp0\detect_msvc_vswhere.cmd" diff --git a/build_files/windows/parse_arguments.cmd b/build_files/windows/parse_arguments.cmd index ccc12836946..8bf714e541a 100644 --- a/build_files/windows/parse_arguments.cmd +++ b/build_files/windows/parse_arguments.cmd @@ -71,6 +71,14 @@ if NOT "%1" == "" ( ) else if "%1" == "2022b" ( set BUILD_VS_YEAR=2022 set VSWHERE_ARGS=-products Microsoft.VisualStudio.Product.BuildTools + ) else if "%1" == "2026" ( + set BUILD_VS_YEAR=2026 + ) else if "%1" == "2026i" ( + set BUILD_VS_YEAR=2026 + set VSWHERE_ARGS=-prerelease + ) else if "%1" == "2026b" ( + set BUILD_VS_YEAR=2026 + set VSWHERE_ARGS=-products Microsoft.VisualStudio.Product.BuildTools ) else if "%1" == "packagename" ( set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DCPACK_OVERRIDE_PACKAGENAME="%2" shift /1 diff --git a/build_files/windows/show_help.cmd b/build_files/windows/show_help.cmd index 83c3fd61fa5..2863a2b3195 100644 --- a/build_files/windows/show_help.cmd +++ b/build_files/windows/show_help.cmd @@ -29,6 +29,9 @@ echo - 2019b ^(build with visual studio 2019 Build Tools^) echo - 2022 ^(build with visual studio 2022^) echo - 2022pre ^(build with visual studio 2022 pre-release^) echo - 2022b ^(build with visual studio 2022 Build Tools^) +echo - 2026 ^(build with visual studio 2026^) +echo - 2026i ^(build with visual studio 2026 insiders^) +echo - 2026b ^(build with visual studio 2026 Build Tools^) echo - clang ^(enable building with clang - default on ARM64^) echo - msvc ^(enable building with msvc - default on x64, unsupported on ARM64^)