mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-15 02:49:42 -05:00
VS: Exclude VS 2019 instances when using VS 2017 generator
Filter instances reported by the VS Installer to consider only VS 2017 instances for the "Visual Studio 15 2017" generator. Fixes: #18721
This commit is contained in:
@@ -295,6 +295,9 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: Add a way for caller to specify other versions.
|
||||
std::wstring wantVersion = std::to_wstring(15) + L'.';
|
||||
|
||||
SmartCOMPtr<ISetupInstance> instance;
|
||||
while (SUCCEEDED(enumInstances->Next(1, &instance, NULL)) && instance) {
|
||||
SmartCOMPtr<ISetupInstance2> instance2 = NULL;
|
||||
@@ -310,6 +313,12 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
|
||||
instance = instance2 = NULL;
|
||||
|
||||
if (isInstalled) {
|
||||
// We are looking for a specific major version.
|
||||
if (instanceInfo.Version.size() < wantVersion.size() ||
|
||||
instanceInfo.Version.substr(0, wantVersion.size()) != wantVersion) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!this->SpecifiedVSInstallLocation.empty()) {
|
||||
// We are looking for a specific instance.
|
||||
std::string currentVSLocation = instanceInfo.GetInstallLocation();
|
||||
|
||||
Reference in New Issue
Block a user