diff options
author | Brad King <brad.king@kitware.com> | 2023-04-03 15:24:55 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-04-05 16:06:22 (GMT) |
commit | 8ecb6459345c550b77d8f689ed397137f2855fca (patch) | |
tree | 2b40b1436ee7da0ead3fbc44fc5349bad53d8f59 /Tests | |
parent | f90c8ab54ebd751600f525a3e548841e6aa16049 (diff) | |
download | CMake-8ecb6459345c550b77d8f689ed397137f2855fca.zip CMake-8ecb6459345c550b77d8f689ed397137f2855fca.tar.gz CMake-8ecb6459345c550b77d8f689ed397137f2855fca.tar.bz2 |
VS: Select Windows SDK matching WindowsSDKVersion env var
In an environment established by `vcvarsall.bat` or similar, this
environment variable may be set to select a Windows SDK version.
If the VS generator is used in such an environment, use that SDK.
This is similar to how `CMAKE_GENERATOR_INSTANCE` defaults using
a `VS##0COMNTOOLS` environment variable.
Fixes: #17992
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake | 8 | ||||
-rw-r--r-- | Tests/RunCMake/GeneratorPlatform/VersionExists.cmake | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake index ffd105c..233eb0a 100644 --- a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake @@ -28,6 +28,8 @@ else() endif() if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio (1[4567])( 20[0-9][0-9])?$") + unset(ENV{WindowsSDKVersion}) + set(RunCMake_GENERATOR_PLATFORM "Test Platform,nocomma") run_cmake(BadFieldNoComma) set(RunCMake_GENERATOR_PLATFORM "Test Platform,unknown=") @@ -99,5 +101,11 @@ if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio (1[4567])( 20[0-9][0-9])?$") run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=${test_version} -DCMAKE_POLICY_DEFAULT_CMP0149=NEW) endforeach() endif() + foreach(expect_version IN LISTS kits) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-WindowsSDKVersion-${expect_version}") + set(ENV{WindowsSDKVersion} "${expect_version}\\") + run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_POLICY_DEFAULT_CMP0149=NEW) + unset(ENV{WindowsSDKVersion}) + endforeach() endif() endif() diff --git a/Tests/RunCMake/GeneratorPlatform/VersionExists.cmake b/Tests/RunCMake/GeneratorPlatform/VersionExists.cmake index 5369ca0..5c30e2b 100644 --- a/Tests/RunCMake/GeneratorPlatform/VersionExists.cmake +++ b/Tests/RunCMake/GeneratorPlatform/VersionExists.cmake @@ -1,4 +1,5 @@ cmake_policy(GET CMP0149 cmp0149) message(STATUS "CMP0149='${cmp0149}'") message(STATUS "CMAKE_SYSTEM_VERSION='${CMAKE_SYSTEM_VERSION}'") +message(STATUS "ENV{WindowsSDKVersion}='$ENV{WindowsSDKVersion}'") message(STATUS "CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION='${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}'") |