| 3489 | } |
| 3490 | |
| 3491 | bool cmTarget::GetMappedConfigNew(std::string desiredConfig, cmValue& loc, |
| 3492 | cmValue& imp, std::string& suffix) const |
| 3493 | { |
| 3494 | desiredConfig = cmSystemTools::UpperCase(desiredConfig); |
| 3495 | |
| 3496 | // Get configuration mapping, if present. |
| 3497 | cmList mappedConfigs; |
| 3498 | if (!desiredConfig.empty()) { |
| 3499 | std::string mapProp = cmStrCat("MAP_IMPORTED_CONFIG_", desiredConfig); |
| 3500 | if (cmValue mapValue = this->GetProperty(mapProp)) { |
| 3501 | mappedConfigs.assign(cmSystemTools::UpperCase(*mapValue), |
| 3502 | cmList::EmptyElements::Yes); |
| 3503 | } |
| 3504 | } |
| 3505 | |
| 3506 | // Get imported configurations, if specified. |
| 3507 | if (cmValue iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) { |
| 3508 | cmList const availableConfigs{ cmSystemTools::UpperCase(*iconfigs) }; |
| 3509 | |
| 3510 | if (!mappedConfigs.empty()) { |
| 3511 | for (auto const& c : mappedConfigs) { |
| 3512 | if (cm::contains(availableConfigs, c)) { |
| 3513 | this->GetLocation(c, loc, imp, suffix); |
| 3514 | return true; |
| 3515 | } |
| 3516 | } |
| 3517 | |
| 3518 | // If a configuration mapping was specified, but no matching |
| 3519 | // configuration was found, we don't want to try anything else. |
| 3520 | return false; |
| 3521 | } |
| 3522 | |
| 3523 | // There is no mapping; try the requested configuration first. |
| 3524 | if (cm::contains(availableConfigs, desiredConfig)) { |
| 3525 | this->GetLocation(desiredConfig, loc, imp, suffix); |
| 3526 | return true; |
| 3527 | } |
| 3528 | |
| 3529 | // If there is no mapping and the requested configuration is not one of |
| 3530 | // the available configurations, just take the first available |
| 3531 | // configuration. |
| 3532 | this->GetLocation(availableConfigs[0], loc, imp, suffix); |
| 3533 | return true; |
| 3534 | } |
| 3535 | |
| 3536 | if (!mappedConfigs.empty()) { |
| 3537 | for (auto const& c : mappedConfigs) { |
| 3538 | if (this->GetLocation(c, loc, imp, suffix)) { |
| 3539 | return true; |
| 3540 | } |
| 3541 | } |
| 3542 | |
| 3543 | // If a configuration mapping was specified, but no matching |
| 3544 | // configuration was found, we don't want to try anything else. |
| 3545 | return false; |
| 3546 | } |
| 3547 | |
| 3548 | // There is no mapping and no explicit list of configurations; the only |
no test coverage detected