| 551 | } |
| 552 | |
| 553 | bool cmGlobalVisualStudioVersionedGenerator::SetGeneratorInstance( |
| 554 | std::string const& i, cmMakefile* mf) |
| 555 | { |
| 556 | if (this->LastGeneratorInstanceString && |
| 557 | i == *(this->LastGeneratorInstanceString)) { |
| 558 | this->SetVSVersionVar(mf); |
| 559 | return true; |
| 560 | } |
| 561 | |
| 562 | if (!this->ParseGeneratorInstance(i, mf)) { |
| 563 | return false; |
| 564 | } |
| 565 | |
| 566 | if (!this->GeneratorInstanceVersion.empty()) { |
| 567 | std::string const majorStr = VSVersionToMajorString(this->Version); |
| 568 | cmsys::RegularExpression versionRegex( |
| 569 | cmStrCat('^', majorStr, R"(\.[0-9]+\.[0-9]+\.[0-9]+$)")); |
| 570 | if (!versionRegex.find(this->GeneratorInstanceVersion)) { |
| 571 | mf->IssueMessage( |
| 572 | MessageType::FATAL_ERROR, |
| 573 | cmStrCat("Generator\n" |
| 574 | " ", |
| 575 | this->GetName(), |
| 576 | "\n" |
| 577 | "given instance specification\n" |
| 578 | " ", |
| 579 | i, |
| 580 | "\n" |
| 581 | "but the version field is not 4 integer components" |
| 582 | " starting in ", |
| 583 | majorStr, '.')); |
| 584 | return false; |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | std::string vsInstance; |
| 589 | if (!i.empty()) { |
| 590 | vsInstance = i; |
| 591 | if (!this->vsSetupAPIHelper.SetVSInstance( |
| 592 | this->GeneratorInstance, this->GeneratorInstanceVersion)) { |
| 593 | std::ostringstream e; |
| 594 | /* clang-format off */ |
| 595 | e << |
| 596 | "Generator\n" |
| 597 | " " << this->GetName() << "\n" |
| 598 | "could not find specified instance of Visual Studio:\n" |
| 599 | " " << i; |
| 600 | /* clang-format on */ |
| 601 | if (!this->GeneratorInstance.empty() && |
| 602 | this->GeneratorInstanceVersion.empty() && |
| 603 | cmSystemTools::FileIsDirectory(this->GeneratorInstance)) { |
| 604 | e << "\n" |
| 605 | "The directory exists, but the instance is not known to the " |
| 606 | "Visual Studio Installer, and no 'version=' field was given."; |
| 607 | } |
| 608 | mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); |
| 609 | return false; |
| 610 | } |
no test coverage detected