| 404 | } |
| 405 | |
| 406 | bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance() |
| 407 | { |
| 408 | bool isVSInstanceExists = false; |
| 409 | if (!chosenInstanceInfo.VSInstallLocation.empty()) { |
| 410 | return true; |
| 411 | } |
| 412 | |
| 413 | if (this->IsEWDKEnabled()) { |
| 414 | std::string envWindowsSdkDir81; |
| 415 | std::string envVSVersion; |
| 416 | std::string envVsInstallDir; |
| 417 | |
| 418 | cmSystemTools::GetEnv("WindowsSdkDir_81", envWindowsSdkDir81); |
| 419 | cmSystemTools::GetEnv("VisualStudioVersion", envVSVersion); |
| 420 | cmSystemTools::GetEnv("VSINSTALLDIR", envVsInstallDir); |
| 421 | if (envVSVersion.empty() || envVsInstallDir.empty()) { |
| 422 | return false; |
| 423 | } |
| 424 | |
| 425 | chosenInstanceInfo.VSInstallLocation = envVsInstallDir; |
| 426 | chosenInstanceInfo.Version = envVSVersion; |
| 427 | if (!LoadVSInstanceVCToolsetVersion(chosenInstanceInfo)) { |
| 428 | return false; |
| 429 | } |
| 430 | chosenInstanceInfo.IsWin10SDKInstalled = true; |
| 431 | chosenInstanceInfo.IsWin81SDKInstalled = !envWindowsSdkDir81.empty(); |
| 432 | return true; |
| 433 | } |
| 434 | |
| 435 | std::string envVSCommonToolsDir; |
| 436 | std::string envVSCommonToolsDirEnvName = |
| 437 | cmStrCat("VS", this->Version, "0COMNTOOLS"); |
| 438 | |
| 439 | if (cmSystemTools::GetEnv(envVSCommonToolsDirEnvName, envVSCommonToolsDir)) { |
| 440 | cmSystemTools::ConvertToUnixSlashes(envVSCommonToolsDir); |
| 441 | } |
| 442 | |
| 443 | bool specifiedLocationNotSpecifiedVersion = false; |
| 444 | |
| 445 | SmartCOMPtr<ISetupInstance> instance; |
| 446 | |
| 447 | std::vector<VSInstanceInfo> vecVSInstancesAll; |
| 448 | |
| 449 | // Enumerate VS instances with either COM interface or Vswhere |
| 450 | if (!EnumerateVSInstancesWithCOM(vecVSInstancesAll) && |
| 451 | !EnumerateVSInstancesWithVswhere(vecVSInstancesAll) && |
| 452 | this->SpecifiedVSInstallLocation.empty()) { |
| 453 | return false; |
| 454 | } |
| 455 | |
| 456 | std::string const wantVersion = cmStrCat(this->Version, '.'); |
| 457 | |
| 458 | std::vector<VSInstanceInfo> vecVSInstances; |
| 459 | for (auto const& instanceInfo : vecVSInstancesAll) { |
| 460 | // We are looking for a specific major version. |
| 461 | if (instanceInfo.Version.size() < wantVersion.size() || |
| 462 | instanceInfo.Version.substr(0, wantVersion.size()) != wantVersion) { |
| 463 | continue; |
no test coverage detected