summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalVisualStudio14Generator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-08-08 17:31:31 (GMT)
committerBrad King <brad.king@kitware.com>2023-08-10 13:33:20 (GMT)
commitbba1a23da9d64c4ef8d68d22af7b5c93727b66a7 (patch)
treed97cb536680eb40bf93998fe082ee7dd717fc0a2 /Source/cmGlobalVisualStudio14Generator.cxx
parent209973e510be9555268eb7b5722a56be60661130 (diff)
downloadCMake-bba1a23da9d64c4ef8d68d22af7b5c93727b66a7.zip
CMake-bba1a23da9d64c4ef8d68d22af7b5c93727b66a7.tar.gz
CMake-bba1a23da9d64c4ef8d68d22af7b5c93727b66a7.tar.bz2
VS: Consolidate Windows SDK major version selection dispatch
Make logic choosing between Windows 10 SDKs and the Windows 8.1 SDK easier to follow by consolidating it in the VS 14 generator. The only information we need from VS 15+ generators is whether the 8.1 SDK is installed.
Diffstat (limited to 'Source/cmGlobalVisualStudio14Generator.cxx')
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx21
1 files changed, 20 insertions, 1 deletions
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index 20aa0b0..e74c211 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -140,9 +140,23 @@ bool cmGlobalVisualStudio14Generator::MatchesGeneratorName(
bool cmGlobalVisualStudio14Generator::InitializePlatformWindows(cmMakefile* mf)
{
- if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) {
+ // If we are targeting Windows 10+, we select a Windows 10 SDK.
+ // If no Windows 8.1 SDK is installed, which is possible with VS 2017 and
+ // higher, then we must choose a Windows 10 SDK anyway.
+ if (cmHasLiteralPrefix(this->SystemVersion, "10.0") ||
+ !this->IsWin81SDKInstalled()) {
return this->SelectWindows10SDK(mf);
}
+
+ // 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 &&
+ !cmSystemTools::VersionCompareGreater(this->SystemVersion, "8.1")) {
+ this->SetWindowsTargetPlatformVersion("8.1", mf);
+ return this->VerifyNoGeneratorPlatformVersion(
+ mf, "with the Windows 8.1 SDK installed");
+ }
+
return this->VerifyNoGeneratorPlatformVersion(mf);
}
@@ -296,6 +310,11 @@ bool cmGlobalVisualStudio14Generator::IsWindowsStoreToolsetInstalled() const
cmSystemTools::KeyWOW64_32);
}
+bool cmGlobalVisualStudio14Generator::IsWin81SDKInstalled() const
+{
+ return true;
+}
+
std::string cmGlobalVisualStudio14Generator::GetWindows10SDKMaxVersion(
cmMakefile* mf) const
{