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 /Source | |
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 'Source')
-rw-r--r-- | Source/cmGlobalVisualStudio14Generator.cxx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 0f9a334..4300d5c 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -437,7 +437,17 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion( return std::string(); } - if (mf->GetPolicyStatus(cmPolicies::CMP0149) != cmPolicies::NEW) { + if (mf->GetPolicyStatus(cmPolicies::CMP0149) == cmPolicies::NEW) { + if (cm::optional<std::string> const envVer = + cmSystemTools::GetEnvVar("WindowsSDKVersion")) { + // Look for a SDK exactly matching the environment variable. + for (std::string const& i : sdks) { + if (cmSystemTools::VersionCompareEqual(i, *envVer)) { + return i; + } + } + } + } else { // Look for a SDK exactly matching the target Windows version. for (std::string const& i : sdks) { if (cmSystemTools::VersionCompareEqual(i, this->SystemVersion)) { |