summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalVisualStudio14Generator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-01-12 15:53:45 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-01-12 15:53:45 (GMT)
commitae7398c0a7d2a094f932fada3e4d0675a30afb6a (patch)
treeb90e5ea6f0d052c7d22aaf1a71cbe1c78c56aacc /Source/cmGlobalVisualStudio14Generator.cxx
parent3e4da6144723450a287a78690d1f9e348c85a4e7 (diff)
parenta57caf7eecdfe61e4ac5f63b145fc9269610f3f0 (diff)
downloadCMake-ae7398c0a7d2a094f932fada3e4d0675a30afb6a.zip
CMake-ae7398c0a7d2a094f932fada3e4d0675a30afb6a.tar.gz
CMake-ae7398c0a7d2a094f932fada3e4d0675a30afb6a.tar.bz2
Merge topic 'vs-win10-sdk'
a57caf7e VS: Fix Windows 10 SDK version selection (#15831) ad594de8 cmSystemTools: Add VersionCompareEqual helper c173e37f VS: Do not select a partial Windows 10 SDK folder (#15831)
Diffstat (limited to 'Source/cmGlobalVisualStudio14Generator.cxx')
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx42
1 files changed, 25 insertions, 17 deletions
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index a05ac24..f151d80 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -231,6 +231,16 @@ cmGlobalVisualStudio14Generator::IsWindowsStoreToolsetInstalled() const
win10SDK, cmSystemTools::KeyWOW64_32);
}
+#if defined(_WIN32) && !defined(__CYGWIN__)
+struct NoWindowsH
+{
+ bool operator()(std::string const& p)
+ {
+ return !cmSystemTools::FileExists(p + "/um/windows.h", true);
+ }
+};
+#endif
+
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
{
@@ -254,6 +264,12 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
std::string path = win10Root + "Include/*";
// Grab the paths of the different SDKs that are installed
cmSystemTools::GlobDirs(path, sdks);
+
+ // Skip SDKs that do not contain <um/windows.h> because that indicates that
+ // only the UCRT MSIs were installed for them.
+ sdks.erase(std::remove_if(sdks.begin(), sdks.end(), NoWindowsH()),
+ sdks.end());
+
if (!sdks.empty())
{
// Only use the filename, which will be the SDK version.
@@ -263,29 +279,21 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
*i = cmSystemTools::GetFilenameName(*i);
}
- // Sort the results to make sure we select the most recent one that
- // has a version less or equal to our version of the operating system
+ // Sort the results to make sure we select the most recent one.
std::sort(sdks.begin(), sdks.end(), cmSystemTools::VersionCompareGreater);
- // Select a suitable SDK version.
- if (this->SystemVersion == "10.0")
- {
- // Use the latest Windows 10 SDK since no build version was given.
- return sdks.at(0);
- }
- else
+ // Look for a SDK exactly matching the requested target version.
+ for (std::vector<std::string>::iterator i = sdks.begin();
+ i != sdks.end(); ++i)
{
- // Find the SDK less or equal to our specified version
- for (std::vector<std::string>::iterator i = sdks.begin();
- i != sdks.end(); ++i)
+ if (cmSystemTools::VersionCompareEqual(*i, this->SystemVersion))
{
- if (!cmSystemTools::VersionCompareGreater(*i, this->SystemVersion))
- {
- // This is the most recent SDK that we can run safely
- return *i;
- }
+ return *i;
}
}
+
+ // Use the latest Windows 10 SDK since the exact version is not available.
+ return sdks.at(0);
}
#endif
// Return an empty string