MCPcopy Create free account
hub / github.com/Kitware/CMake / GetMappedConfig

Method GetMappedConfig

Source/cmTarget.cxx:3252–3316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3250}
3251
3252bool cmTarget::GetMappedConfig(std::string const& desiredConfig, cmValue& loc,
3253 cmValue& imp, std::string& suffix) const
3254{
3255 switch (this->GetPolicyStatusCMP0200()) {
3256 case cmPolicies::WARN:
3257 if (this->GetMakefile()->PolicyOptionalWarningEnabled(
3258 "CMAKE_POLICY_WARNING_CMP0200")) {
3259 break;
3260 }
3261 CM_FALLTHROUGH;
3262 case cmPolicies::OLD:
3263 return this->GetMappedConfigOld(desiredConfig, loc, imp, suffix);
3264 case cmPolicies::NEW:
3265 return this->GetMappedConfigNew(desiredConfig, loc, imp, suffix);
3266 }
3267
3268 cmValue newLoc;
3269 cmValue newImp;
3270 std::string newSuffix;
3271
3272 bool const newResult =
3273 this->GetMappedConfigNew(desiredConfig, newLoc, newImp, newSuffix);
3274
3275 auto configFromSuffix = [](cm::string_view s) -> cm::string_view {
3276 return s.empty() ? "(none)"_s : s.substr(1);
3277 };
3278
3279 if (!this->GetMappedConfigOld(desiredConfig, loc, imp, suffix)) {
3280 if (newResult) {
3281 // NEW policy found a configuration, OLD did not.
3282 cm::string_view newConfig = configFromSuffix(newSuffix);
3283 std::string const err = cmStrCat(
3284 cmPolicies::GetPolicyWarning(cmPolicies::CMP0200),
3285 "\nConfiguration selection for imported target \"", this->GetName(),
3286 "\" failed, but would select configuration \"", newConfig,
3287 "\" under the NEW policy.\n");
3288 this->GetMakefile()->IssueMessage(MessageType::AUTHOR_WARNING, err);
3289 }
3290
3291 return false;
3292 }
3293
3294 cm::string_view oldConfig = configFromSuffix(suffix);
3295 if (!newResult) {
3296 // NEW policy did not find a configuration, OLD did.
3297 std::string const err =
3298 cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0200),
3299 "\nConfiguration selection for imported target \"",
3300 this->GetName(), "\" selected configuration \"", oldConfig,
3301 "\", but would fail under the NEW policy.\n");
3302 this->GetMakefile()->IssueMessage(MessageType::AUTHOR_WARNING, err);
3303 } else if (suffix != newSuffix) {
3304 // OLD and NEW policies found different configurations.
3305 cm::string_view newConfig = configFromSuffix(newSuffix);
3306 std::string const err =
3307 cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0200),
3308 "\nConfiguration selection for imported target \"",
3309 this->GetName(), "\" selected configuration \"", oldConfig,

Callers 5

ImportedGetFullPathMethod · 0.95
EvaluateMethod · 0.80
EvaluateMethod · 0.80
ComputeImportInfoMethod · 0.80

Calls 9

GetMakefileMethod · 0.95
GetMappedConfigOldMethod · 0.95
GetMappedConfigNewMethod · 0.95
cmStrCatFunction · 0.70
emptyMethod · 0.45
substrMethod · 0.45
GetNameMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected