diff options
author | Gilles Khouzam <gillesk@microsoft.com> | 2017-08-07 17:38:50 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-09-17 17:07:40 (GMT) |
commit | 83ddc4d2891a0bbb06fb1e3daa00245b3c23eddc (patch) | |
tree | 2207fa68f6aef0da1996d61e8acb2f960b0e373a /Source/cmGlobalVisualStudio14Generator.cxx | |
parent | f0c84346ed25f6b8ce3a9f79aece87a58c8a4748 (diff) | |
download | CMake-83ddc4d2891a0bbb06fb1e3daa00245b3c23eddc.zip CMake-83ddc4d2891a0bbb06fb1e3daa00245b3c23eddc.tar.gz CMake-83ddc4d2891a0bbb06fb1e3daa00245b3c23eddc.tar.bz2 |
VS: Do not select a Windows SDK too high for current VS version
Add an internal API for the maximum Windows 10 SDK version supported by
a toolset. For Visual Studio 14 2015 that would be the version
"10.0.14393.0".
Fixes: #17788
Diffstat (limited to 'Source/cmGlobalVisualStudio14Generator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudio14Generator.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index b0db146..c3ddb3e 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -212,6 +212,12 @@ bool cmGlobalVisualStudio14Generator::IsWindowsStoreToolsetInstalled() const cmSystemTools::KeyWOW64_32); } +std::string cmGlobalVisualStudio14Generator::GetWindows10SDKMaxVersion() const +{ + // The last Windows 10 SDK version that VS 2015 can target is 10.0.14393.0. + return "10.0.14393.0"; +} + #if defined(_WIN32) && !defined(__CYGWIN__) struct NoWindowsH { @@ -220,6 +226,20 @@ struct NoWindowsH return !cmSystemTools::FileExists(p + "/um/windows.h", true); } }; +class WindowsSDKTooRecent +{ + std::string const& MaxVersion; + +public: + WindowsSDKTooRecent(std::string const& maxVersion) + : MaxVersion(maxVersion) + { + } + bool operator()(std::string const& v) + { + return cmSystemTools::VersionCompareGreater(v, MaxVersion); + } +}; #endif std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() @@ -276,6 +296,12 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() // Sort the results to make sure we select the most recent one. std::sort(sdks.begin(), sdks.end(), cmSystemTools::VersionCompareGreater); + // Skip SDKs that cannot be used with our toolset. + std::string maxVersion = this->GetWindows10SDKMaxVersion(); + if (!maxVersion.empty()) { + cmEraseIf(sdks, WindowsSDKTooRecent(maxVersion)); + } + // Look for a SDK exactly matching the requested target version. for (std::string const& i : sdks) { if (cmSystemTools::VersionCompareEqual(i, this->SystemVersion)) { |