diff options
author | Harry Mallon <hjmallon@gmail.com> | 2018-11-23 15:36:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-11-26 18:42:50 (GMT) |
commit | f54d28a838ca7d4efbbd0155c4f61c287ae2b9cb (patch) | |
tree | 74d9bbc1fa19c0d9c2ce4ea54e867ecf5bd622be /Source/cmGlobalVisualStudio14Generator.cxx | |
parent | 05a2ca7f87b9ae73f373e9967fde1ee5210e33af (diff) | |
download | CMake-f54d28a838ca7d4efbbd0155c4f61c287ae2b9cb.zip CMake-f54d28a838ca7d4efbbd0155c4f61c287ae2b9cb.tar.gz CMake-f54d28a838ca7d4efbbd0155c4f61c287ae2b9cb.tar.bz2 |
VS: Avoid crash with VS 2015 when all SDKs are higher than 10.0.14393.0
Move the filter added by commit v3.13.0-rc1~72^2~2 (VS: Do not select a
Windows SDK too high for current VS version, 2017-08-07, committed
2018-09-17) to before our check that the remaining list is empty.
Otherwise we crash when dereferencing the first entry of an empty
vector.
Also add a comment explaining where 10.0.14393.0 came from.
Fixes: #18633
Diffstat (limited to 'Source/cmGlobalVisualStudio14Generator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudio14Generator.cxx | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index c3ddb3e..92ee2e0 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -215,6 +215,10 @@ bool cmGlobalVisualStudio14Generator::IsWindowsStoreToolsetInstalled() const std::string cmGlobalVisualStudio14Generator::GetWindows10SDKMaxVersion() const { // The last Windows 10 SDK version that VS 2015 can target is 10.0.14393.0. + // + // "VS 2015 Users: The Windows 10 SDK (15063, 16299, 17134, 17763) is + // officially only supported for VS 2017." From: + // https://blogs.msdn.microsoft.com/chuckw/2018/10/02/windows-10-october-2018-update/ return "10.0.14393.0"; } @@ -287,28 +291,28 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() // only the UCRT MSIs were installed for them. cmEraseIf(sdks, NoWindowsH()); - if (!sdks.empty()) { - // Only use the filename, which will be the SDK version. - for (std::string& i : sdks) { - i = cmSystemTools::GetFilenameName(i); - } + // Only use the filename, which will be the SDK version. + for (std::string& i : sdks) { + i = cmSystemTools::GetFilenameName(i); + } - // 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)); + } - // Skip SDKs that cannot be used with our toolset. - std::string maxVersion = this->GetWindows10SDKMaxVersion(); - if (!maxVersion.empty()) { - cmEraseIf(sdks, WindowsSDKTooRecent(maxVersion)); - } + // Sort the results to make sure we select the most recent one. + std::sort(sdks.begin(), sdks.end(), cmSystemTools::VersionCompareGreater); - // Look for a SDK exactly matching the requested target version. - for (std::string const& i : sdks) { - if (cmSystemTools::VersionCompareEqual(i, this->SystemVersion)) { - return i; - } + // Look for a SDK exactly matching the requested target version. + for (std::string const& i : sdks) { + if (cmSystemTools::VersionCompareEqual(i, this->SystemVersion)) { + return i; } + } + if (!sdks.empty()) { // Use the latest Windows 10 SDK since the exact version is not available. return sdks.at(0); } |