| 1564 | } |
| 1565 | |
| 1566 | void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib, |
| 1567 | cmTargetLinkLibraryType llt) |
| 1568 | { |
| 1569 | cmTarget* tgt = mf.FindTargetToUse(lib); |
| 1570 | { |
| 1571 | bool const isNonImportedTarget = tgt && !tgt->IsImported(); |
| 1572 | |
| 1573 | std::string const libName = |
| 1574 | (isNonImportedTarget && llt != GENERAL_LibraryType) |
| 1575 | ? targetNameGenex(lib) |
| 1576 | : lib; |
| 1577 | this->AppendProperty("LINK_LIBRARIES", |
| 1578 | this->GetDebugGeneratorExpressions(libName, llt), |
| 1579 | mf.GetBacktrace()); |
| 1580 | } |
| 1581 | |
| 1582 | if (cmGeneratorExpression::Find(lib) != std::string::npos || |
| 1583 | (tgt && |
| 1584 | (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY || |
| 1585 | tgt->GetType() == cmStateEnums::OBJECT_LIBRARY)) || |
| 1586 | (this->impl->Name == lib)) { |
| 1587 | return; |
| 1588 | } |
| 1589 | |
| 1590 | this->impl->OriginalLinkLibraries.emplace_back(lib, llt); |
| 1591 | |
| 1592 | // Add the explicit dependency information for libraries. This is |
| 1593 | // simply a set of libraries separated by ";". There should always |
| 1594 | // be a trailing ";". These library names are not canonical, in that |
| 1595 | // they may be "-framework x", "-ly", "/path/libz.a", etc. |
| 1596 | // We shouldn't remove duplicates here because external libraries |
| 1597 | // may be purposefully duplicated to handle recursive dependencies, |
| 1598 | // and we removing one instance will break the link line. Duplicates |
| 1599 | // will be appropriately eliminated at emit time. |
| 1600 | if (this->impl->TargetType >= cmStateEnums::STATIC_LIBRARY && |
| 1601 | this->impl->TargetType <= cmStateEnums::MODULE_LIBRARY && |
| 1602 | (this->GetPolicyStatusCMP0073() == cmPolicies::OLD || |
| 1603 | this->GetPolicyStatusCMP0073() == cmPolicies::WARN)) { |
| 1604 | std::string targetEntry = cmStrCat(this->impl->Name, "_LIB_DEPENDS"); |
| 1605 | std::string dependencies; |
| 1606 | cmValue old_val = mf.GetDefinition(targetEntry); |
| 1607 | if (old_val) { |
| 1608 | dependencies += *old_val; |
| 1609 | } |
| 1610 | switch (llt) { |
| 1611 | case GENERAL_LibraryType: |
| 1612 | dependencies += "general"; |
| 1613 | break; |
| 1614 | case DEBUG_LibraryType: |
| 1615 | dependencies += "debug"; |
| 1616 | break; |
| 1617 | case OPTIMIZED_LibraryType: |
| 1618 | dependencies += "optimized"; |
| 1619 | break; |
| 1620 | } |
| 1621 | dependencies += ";"; |
| 1622 | dependencies += lib; |
| 1623 | dependencies += ";"; |
no test coverage detected