VS: Select latest Windows SDK even when targeting Windows 8.1 and below

The policy added by commit f90c8ab54e (VS: Select latest available
Windows SDK version by default, 2023-04-03, v3.27.0-rc1~206^2~1) applied
only when targeting Windows 10+.  Apply it to older versions too.

Fixes: #25170
Issue: #16202
This commit is contained in:
Brad King
2023-08-08 16:43:14 -04:00
parent ae97d82e83
commit 89b611ab32
4 changed files with 24 additions and 5 deletions

View File

@@ -217,6 +217,16 @@ bool cmGlobalVisualStudio14Generator::InitializePlatformWindows(cmMakefile* mf)
return this->SelectWindows10SDK(mf);
}
// Under CMP0149 NEW behavior, we search for a Windows 10 SDK even
// when targeting older Windows versions, but it is not required.
if (mf->GetPolicyStatus(cmPolicies::CMP0149) == cmPolicies::NEW) {
std::string const version = this->GetWindows10SDKVersion(mf);
if (!version.empty()) {
this->SetWindowsTargetPlatformVersion(version, mf);
return true;
}
}
// We are not targeting Windows 10+, so fall back to the Windows 8.1 SDK.
// For VS 2019 and above we must explicitly specify it.
if (this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS16 &&