Skip to content
Snippets Groups Projects
Commit a57caf7e authored by Brad King's avatar Brad King
Browse files

VS: Fix Windows 10 SDK version selection (#15831)

In commit v3.4.0-rc1~5^2~1 (VS: Add support for selecting the Windows 10
SDK, 2015-09-30) we added Windows 10 SDK selection choosing the most
recent SDK that is not newer than the target version.  This is backward
because it should be up to the application code to not use APIs newer
than the target version.  It is up to the build system to provide a SDK
that has at least the APIs expected to be available for the target
version.  Furthermore, since the default target version is the host
version of Windows, the old approach breaks when the only SDK available
is for a newer version of Windows.

Fix this by always selecting a Windows 10 SDK if one exists.  Use the
SDK for the exact version if is available.  Otherwise use the latest
version of the SDK available because that will have at least the APIs
expected for the target version.
parent ad594de8
No related branches found
No related tags found
No related merge requests found
......@@ -277,29 +277,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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment