| 631 | } |
| 632 | |
| 633 | void cmPackageInfoReader::AddTargetConfiguration( |
| 634 | cmTarget* target, cm::string_view configuration) const |
| 635 | { |
| 636 | static std::string const icProp = "IMPORTED_CONFIGURATIONS"; |
| 637 | |
| 638 | std::string const& configUpper = cmSystemTools::UpperCase(configuration); |
| 639 | |
| 640 | // Get existing list of imported configurations. |
| 641 | cmList configs; |
| 642 | if (cmValue v = target->GetProperty(icProp)) { |
| 643 | configs.assign(cmSystemTools::UpperCase(*v)); |
| 644 | } else { |
| 645 | // If the existing list is empty, just add the new one and return. |
| 646 | target->SetProperty(icProp, configUpper); |
| 647 | return; |
| 648 | } |
| 649 | |
| 650 | if (cm::contains(configs, configUpper)) { |
| 651 | // If the configuration is already listed, we don't need to do anything. |
| 652 | return; |
| 653 | } |
| 654 | |
| 655 | // Add the new configuration. |
| 656 | configs.append(configUpper); |
| 657 | |
| 658 | // Rebuild the configuration list by extracting any configuration in the |
| 659 | // default configurations and reinserting it at the beginning of the list |
| 660 | // according to the order of the default configurations. |
| 661 | std::vector<std::string> newConfigs; |
| 662 | for (std::string const& c : this->DefaultConfigurations) { |
| 663 | auto ci = std::find(configs.begin(), configs.end(), c); |
| 664 | if (ci != configs.end()) { |
| 665 | newConfigs.emplace_back(std::move(*ci)); |
| 666 | configs.erase(ci); |
| 667 | } |
| 668 | } |
| 669 | for (std::string& c : configs) { |
| 670 | newConfigs.emplace_back(std::move(c)); |
| 671 | } |
| 672 | |
| 673 | target->SetProperty("IMPORTED_CONFIGURATIONS", cmJoin(newConfigs, ";"_s)); |
| 674 | } |
| 675 | |
| 676 | void cmPackageInfoReader::SetImportProperty(cmMakefile* makefile, |
| 677 | cmTarget* target, |
no test coverage detected