From 19d2f069ad87ae8c89406a01e1ef55f174786d67 Mon Sep 17 00:00:00 2001 From: Justin Goshi Date: Mon, 26 Nov 2018 16:16:42 -0800 Subject: [PATCH] Fix VS2015 crash when all installed SDKs are higher than 10.0.14393 --- Source/cmGlobalVisualStudio14Generator.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index c3ddb3e016e..1a249870356 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -287,6 +287,12 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() // only the UCRT MSIs were installed for them. cmEraseIf(sdks, NoWindowsH()); + // Skip SDKs that cannot be used with our toolset. + std::string maxVersion = this->GetWindows10SDKMaxVersion(); + if (!maxVersion.empty()) { + cmEraseIf(sdks, WindowsSDKTooRecent(maxVersion)); + } + if (!sdks.empty()) { // Only use the filename, which will be the SDK version. for (std::string& i : sdks) { @@ -296,12 +302,6 @@ 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)) {