| 3457 | } |
| 3458 | |
| 3459 | void cmLocalGenerator::AppendLinkerTypeFlags(std::string& flags, |
| 3460 | cmGeneratorTarget* target, |
| 3461 | std::string const& config, |
| 3462 | std::string const& linkLanguage) |
| 3463 | { |
| 3464 | switch (target->GetType()) { |
| 3465 | case cmStateEnums::EXECUTABLE: |
| 3466 | case cmStateEnums::SHARED_LIBRARY: |
| 3467 | case cmStateEnums::MODULE_LIBRARY: |
| 3468 | break; |
| 3469 | default: |
| 3470 | return; |
| 3471 | } |
| 3472 | |
| 3473 | auto linkMode = |
| 3474 | cmStrCat("CMAKE_", linkLanguage, target->IsDeviceLink() ? "_DEVICE_" : "_", |
| 3475 | "LINK_MODE"); |
| 3476 | auto mode = this->Makefile->GetDefinition(linkMode); |
| 3477 | if (mode && mode != "DRIVER"_s) { |
| 3478 | return; |
| 3479 | } |
| 3480 | |
| 3481 | auto linkerType = target->GetLinkerTypeProperty(linkLanguage, config); |
| 3482 | if (linkerType.empty()) { |
| 3483 | linkerType = "DEFAULT"; |
| 3484 | } |
| 3485 | auto usingLinker = |
| 3486 | cmStrCat("CMAKE_", linkLanguage, "_USING_", |
| 3487 | target->IsDeviceLink() ? "DEVICE_" : "", "LINKER_", linkerType); |
| 3488 | auto linkerTypeFlags = this->Makefile->GetDefinition(usingLinker); |
| 3489 | if (linkerTypeFlags) { |
| 3490 | if (!linkerTypeFlags.IsEmpty()) { |
| 3491 | auto linkerFlags = cmExpandListWithBacktrace(linkerTypeFlags); |
| 3492 | target->ResolveLinkerWrapper(linkerFlags, linkLanguage); |
| 3493 | this->AppendFlags(flags, linkerFlags); |
| 3494 | } |
| 3495 | } else if (linkerType != "DEFAULT"_s) { |
| 3496 | auto isCMakeLinkerType = [](std::string const& type) -> bool { |
| 3497 | return std::all_of(type.cbegin(), type.cend(), cmsysString_isupper); |
| 3498 | }; |
| 3499 | if (isCMakeLinkerType(linkerType)) { |
| 3500 | this->IssueMessage( |
| 3501 | MessageType::FATAL_ERROR, |
| 3502 | cmStrCat("LINKER_TYPE '", linkerType, |
| 3503 | "' is unknown or not supported by this toolchain.")); |
| 3504 | } else { |
| 3505 | this->IssueMessage( |
| 3506 | MessageType::FATAL_ERROR, |
| 3507 | cmStrCat("LINKER_TYPE '", linkerType, |
| 3508 | "' is unknown. Did you forget to define the '", usingLinker, |
| 3509 | "' variable?")); |
| 3510 | } |
| 3511 | } |
| 3512 | } |
| 3513 | |
| 3514 | void cmLocalGenerator::AddTargetTypeLinkerFlags( |
| 3515 | std::string& flags, cmGeneratorTarget const* target, std::string const& lang, |
no test coverage detected