diff options
author | Brad King <brad.king@kitware.com> | 2017-02-20 14:46:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-02-21 18:47:54 (GMT) |
commit | 2da0838c64b6d43fd12eecb5d65ac458a335b266 (patch) | |
tree | 08459ec2d741fd419fa21b2ec61a9e284932934f /Source/cmGlobalVisualStudio15Generator.cxx | |
parent | 6cbad490c2fdbd9bdc67b406b9f2dcdc21e08ddb (diff) | |
download | CMake-2da0838c64b6d43fd12eecb5d65ac458a335b266.zip CMake-2da0838c64b6d43fd12eecb5d65ac458a335b266.tar.gz CMake-2da0838c64b6d43fd12eecb5d65ac458a335b266.tar.bz2 |
VS2017: If Win 8.1 SDK is not available, use Win 10 SDK
We try to choose the Windows SDK version based on the version of Windows
targeted by the build. However, if using VS 2017 without the Windows
8.1 SDK installed then we must fall back to the Windows 10 SDK even when
targeting an older version of Windows.
Inspired-by: gnaggnoyil <gnaggnoyil@gmail.com>
Diffstat (limited to 'Source/cmGlobalVisualStudio15Generator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudio15Generator.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Source/cmGlobalVisualStudio15Generator.cxx b/Source/cmGlobalVisualStudio15Generator.cxx index d11ee7c..2312bc0 100644 --- a/Source/cmGlobalVisualStudio15Generator.cxx +++ b/Source/cmGlobalVisualStudio15Generator.cxx @@ -109,6 +109,18 @@ void cmGlobalVisualStudio15Generator::WriteSLNHeader(std::ostream& fout) } } +bool cmGlobalVisualStudio15Generator::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()) { + return cmGlobalVisualStudio14Generator::InitializeWindows(mf); + } + // Otherwise we must choose a Win 10 SDK even if we are not targeting + // Windows 10. + return this->SelectWindows10SDK(mf, false); +} + bool cmGlobalVisualStudio15Generator::SelectWindowsStoreToolset( std::string& toolset) const { @@ -135,6 +147,28 @@ bool cmGlobalVisualStudio15Generator::IsWindowsStoreToolsetInstalled() const return vsSetupAPIHelper.IsWin10SDKInstalled(); } +bool cmGlobalVisualStudio15Generator::IsWin81SDKInstalled() const +{ + // Does the VS installer tool know about one? + if (vsSetupAPIHelper.IsWin81SDKInstalled()) { + return true; + } + + // Does the registry know about one (e.g. from VS 2015)? + std::string win81Root; + if (cmSystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" + "Windows Kits\\Installed Roots;KitsRoot81", + win81Root, cmSystemTools::KeyWOW64_32) || + cmSystemTools::ReadRegistryValue( + "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\" + "Windows Kits\\Installed Roots;KitsRoot81", + win81Root, cmSystemTools::KeyWOW64_32)) { + return true; + } + return false; +} + std::string cmGlobalVisualStudio15Generator::FindMSBuildCommand() { std::string msbuild; |