From 35bf9ded3b116209ca864eff2da481c22117e17d Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 19 Feb 2019 09:22:18 -0500 Subject: VS: Factor out a method to set the Windows SDK version internally --- Source/cmGlobalVisualStudio14Generator.cxx | 13 ++++++++++--- Source/cmGlobalVisualStudio14Generator.h | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index a0a9558..2025867 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -158,14 +158,22 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf, bool required) { // Find the default version of the Windows 10 SDK. - this->WindowsTargetPlatformVersion = this->GetWindows10SDKVersion(); - if (required && this->WindowsTargetPlatformVersion.empty()) { + std::string const version = this->GetWindows10SDKVersion(); + if (required && version.empty()) { std::ostringstream e; e << "Could not find an appropriate version of the Windows 10 SDK" << " installed on this machine"; mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); return false; } + this->SetWindowsTargetPlatformVersion(version, mf); + return true; +} + +void cmGlobalVisualStudio14Generator::SetWindowsTargetPlatformVersion( + std::string const& version, cmMakefile* mf) +{ + this->WindowsTargetPlatformVersion = version; if (!cmSystemTools::VersionCompareEqual(this->WindowsTargetPlatformVersion, this->SystemVersion)) { std::ostringstream e; @@ -175,7 +183,6 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf, } mf->AddDefinition("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION", this->WindowsTargetPlatformVersion.c_str()); - return true; } bool cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset( diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index 32008b0..6e12d3e 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -40,6 +40,9 @@ protected: virtual bool SelectWindows10SDK(cmMakefile* mf, bool required); + void SetWindowsTargetPlatformVersion(std::string const& version, + cmMakefile* mf); + // Used to verify that the Desktop toolset for the current generator is // installed on the machine. bool IsWindowsDesktopToolsetInstalled() const override; -- cgit v0.12 From 4dab8e69bd46b6aa85a97c4d23e9d894fc5fbcf6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 19 Feb 2019 09:22:55 -0500 Subject: VS: Tell VS 2019 to use Windows SDK 8.1 explicitly when needed VS 2019 does not default to the 8.1 SDK as VS 2017 and VS 2015 did. When `CMAKE_SYSTEM_VERSION` is 8.1 or lower, select the 8.1 SDK explicitly. Fixes: #18927 --- Source/cmGlobalVisualStudioVersionedGenerator.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 913fc4a..2f9eb3f 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -401,6 +401,12 @@ bool cmGlobalVisualStudioVersionedGenerator::InitializeWindows(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::VS16 && + !cmSystemTools::VersionCompareGreater(this->SystemVersion, "8.1")) { + this->SetWindowsTargetPlatformVersion("8.1", mf); + return true; + } return cmGlobalVisualStudio14Generator::InitializeWindows(mf); } // Otherwise we must choose a Win 10 SDK even if we are not targeting -- cgit v0.12