summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx21
-rw-r--r--Source/cmGlobalVisualStudio14Generator.h2
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.cxx20
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.h4
4 files changed, 23 insertions, 24 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
{
diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h
index f59a323..d8a5230 100644
--- a/Source/cmGlobalVisualStudio14Generator.h
+++ b/Source/cmGlobalVisualStudio14Generator.h
@@ -40,6 +40,8 @@ protected:
// of the toolset is installed
bool IsWindowsStoreToolsetInstalled() const;
+ virtual bool IsWin81SDKInstalled() const;
+
bool InitializePlatformWindows(cmMakefile* mf) override;
bool VerifyNoGeneratorPlatformVersion(
cmMakefile* mf,
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index 602b42f..14c7d0f 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -901,26 +901,6 @@ cmGlobalVisualStudioVersionedGenerator::FindAuxToolset(
return AuxToolset::PropsMissing;
}
-bool cmGlobalVisualStudioVersionedGenerator::InitializePlatformWindows(
- cmMakefile* mf)
-{
- // If the Win 8.1 SDK is installed then we can select a SDK matching
- // the target Windows version.
- if (this->IsWin81SDKInstalled()) {
- // VS 2019 does not default to 8.1 so specify it explicitly when needed.
- 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 cmGlobalVisualStudio14Generator::InitializePlatformWindows(mf);
- }
- // Otherwise we must choose a Win 10 SDK even if we are not targeting
- // Windows 10.
- return this->SelectWindows10SDK(mf);
-}
-
bool cmGlobalVisualStudioVersionedGenerator::SelectWindowsStoreToolset(
std::string& toolset) const
{
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h
index 8712459..8f0345f 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.h
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.h
@@ -72,10 +72,8 @@ protected:
// of the toolset is installed
bool IsWindowsStoreToolsetInstalled() const;
- bool InitializePlatformWindows(cmMakefile* mf) override;
-
// Check for a Win 8 SDK known to the registry or VS installer tool.
- bool IsWin81SDKInstalled() const;
+ bool IsWin81SDKInstalled() const override;
std::string GetWindows10SDKMaxVersionDefault(cmMakefile*) const override;