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

Method AddPerLanguageLinkFlags

Source/cmLocalGenerator.cxx:3361–3420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3359}
3360
3361void cmLocalGenerator::AddPerLanguageLinkFlags(std::string& flags,
3362 cmGeneratorTarget const* target,
3363 std::string const& lang,
3364 std::string const& config)
3365{
3366 switch (target->GetType()) {
3367 case cmStateEnums::MODULE_LIBRARY:
3368 case cmStateEnums::SHARED_LIBRARY:
3369 case cmStateEnums::EXECUTABLE:
3370 break;
3371 default:
3372 return;
3373 }
3374
3375 std::string langLinkFlags =
3376 this->Makefile->GetSafeDefinition(cmStrCat("CMAKE_", lang, "_LINK_FLAGS"));
3377
3378 switch (target->GetPolicyStatusCMP0210()) {
3379 case cmPolicies::WARN:
3380 // WARN only when CMAKE_<LANG>_LINK_FLAGS is set, and when the current
3381 // target is not an executable, and CMAKE_<LANG>_LINK_FLAGS is not equal
3382 // to CMAKE_EXECUTABLE_CREATE_<LANG>_FLAGS. This warns users trying to
3383 // use the NEW behavior on old projects (since CMake will be ignoring
3384 // their wishes), while also exempting cases when the latter variable
3385 // (substituted for the former spelling under the NEW behavior) is being
3386 // used legitimately by CMake.
3387 // Additionally, WARN at most once per language, instead of on every
3388 // target.
3389 if (!langLinkFlags.empty() &&
3390 target->GetType() != cmStateEnums::EXECUTABLE &&
3391 langLinkFlags !=
3392 this->Makefile->GetSafeDefinition(
3393 cmStrCat("CMAKE_EXECUTABLE_CREATE_", lang, "_FLAGS")) &&
3394 this->GlobalGenerator->ShouldWarnCMP0210(lang)) {
3395 this->IssueMessage(
3396 MessageType::AUTHOR_WARNING,
3397 cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0210), "\n",
3398 "For compatibility with older versions of CMake, ",
3399 "CMAKE_", lang, "_LINK_FLAGS will be ignored for all ",
3400 "non-EXECUTABLE targets which use these flags."));
3401 }
3402 CM_FALLTHROUGH;
3403 case cmPolicies::OLD:
3404 // OLD behavior is to do nothing here, since the use of
3405 // CMAKE_<LANG>_LINK_FLAGS for EXECUTABLEs is handled elsewhere.
3406 break;
3407 case cmPolicies::NEW:
3408 // NEW behavior is to support per-language link flags for all target
3409 // types.
3410 this->AppendLinkFlagsWithParsing(flags, langLinkFlags, target, lang);
3411 if (!config.empty()) {
3412 std::string lankLinkFlagsConfig =
3413 this->Makefile->GetSafeDefinition(cmStrCat(
3414 "CMAKE_", lang, "_LINK_FLAGS_", cmSystemTools::UpperCase(config)));
3415 this->AppendLinkFlagsWithParsing(flags, lankLinkFlagsConfig, target,
3416 lang);
3417 }
3418 break;

Callers 7

GetTargetFlagsMethod · 0.95
CreateBuildSettingsMethod · 0.80
WriteExecutableRuleMethod · 0.80
OutputBuildToolMethod · 0.80
ComputeLinkOptionsMethod · 0.80

Calls 6

IssueMessageMethod · 0.95
ShouldWarnCMP0210Method · 0.80
cmStrCatFunction · 0.70
GetTypeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected