|
|
@@ -58,10 +58,6 @@ using LinkInterfaceFor = cmGeneratorTarget::LinkInterfaceFor;
|
|
|
const cmsys::RegularExpression FrameworkRegularExpression(
|
|
|
"^(.*/)?([^/]*)\\.framework/(.*)$");
|
|
|
const std::string kINTERFACE_LINK_LIBRARIES = "INTERFACE_LINK_LIBRARIES";
|
|
|
-const std::string kINTERFACE_LINK_LIBRARIES_DIRECT =
|
|
|
- "INTERFACE_LINK_LIBRARIES_DIRECT";
|
|
|
-const std::string kINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE =
|
|
|
- "INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE";
|
|
|
}
|
|
|
|
|
|
template <>
|
|
|
@@ -6671,10 +6667,12 @@ cm::optional<cmLinkItem> cmGeneratorTarget::LookupLinkItem(
|
|
|
return maybeItem;
|
|
|
}
|
|
|
|
|
|
-void cmGeneratorTarget::ExpandLinkItems(
|
|
|
- std::string const& prop, cmBTStringRange entries, std::string const& config,
|
|
|
- cmGeneratorTarget const* headTarget, LinkInterfaceFor interfaceFor,
|
|
|
- LinkInterfaceField field, cmLinkInterface& iface) const
|
|
|
+void cmGeneratorTarget::ExpandLinkItems(std::string const& prop,
|
|
|
+ cmBTStringRange entries,
|
|
|
+ std::string const& config,
|
|
|
+ cmGeneratorTarget const* headTarget,
|
|
|
+ LinkInterfaceFor interfaceFor,
|
|
|
+ cmLinkInterface& iface) const
|
|
|
{
|
|
|
if (entries.empty()) {
|
|
|
return;
|
|
|
@@ -6698,19 +6696,9 @@ void cmGeneratorTarget::ExpandLinkItems(
|
|
|
this, headTarget->LinkerLanguage));
|
|
|
for (std::string const& lib : libs) {
|
|
|
if (cm::optional<cmLinkItem> maybeItem = this->LookupLinkItem(
|
|
|
- lib, cge->GetBacktrace(), &scope,
|
|
|
- field == LinkInterfaceField::Libraries ? LookupSelf::No
|
|
|
- : LookupSelf::Yes)) {
|
|
|
+ lib, cge->GetBacktrace(), &scope, LookupSelf::No)) {
|
|
|
cmLinkItem item = std::move(*maybeItem);
|
|
|
|
|
|
- if (field == LinkInterfaceField::HeadInclude) {
|
|
|
- iface.HeadInclude.emplace_back(std::move(item));
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (field == LinkInterfaceField::HeadExclude) {
|
|
|
- iface.HeadExclude.emplace_back(std::move(item));
|
|
|
- continue;
|
|
|
- }
|
|
|
if (!item.Target) {
|
|
|
// Report explicitly linked object files separately.
|
|
|
std::string const& maybeObj = item.AsStr();
|
|
|
@@ -7181,9 +7169,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
|
|
|
this->GetPolicyStatusCMP0022() != cmPolicies::WARN);
|
|
|
if (cmp0022NEW) {
|
|
|
// CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES.
|
|
|
- haveExplicitLibraries = !this->Target->GetLinkInterfaceEntries().empty() ||
|
|
|
- !this->Target->GetLinkInterfaceDirectEntries().empty() ||
|
|
|
- !this->Target->GetLinkInterfaceDirectExcludeEntries().empty();
|
|
|
+ haveExplicitLibraries = !this->Target->GetLinkInterfaceEntries().empty();
|
|
|
} else {
|
|
|
// CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a
|
|
|
// shared lib or executable.
|
|
|
@@ -7248,24 +7234,15 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
|
|
|
if (cmp0022NEW) {
|
|
|
// The interface libraries are specified by INTERFACE_LINK_LIBRARIES.
|
|
|
// Use its special representation directly to get backtraces.
|
|
|
- this->ExpandLinkItems(
|
|
|
- kINTERFACE_LINK_LIBRARIES, this->Target->GetLinkInterfaceEntries(),
|
|
|
- config, headTarget, interfaceFor, LinkInterfaceField::Libraries, iface);
|
|
|
- this->ExpandLinkItems(kINTERFACE_LINK_LIBRARIES_DIRECT,
|
|
|
- this->Target->GetLinkInterfaceDirectEntries(),
|
|
|
- config, headTarget, interfaceFor,
|
|
|
- LinkInterfaceField::HeadInclude, iface);
|
|
|
- this->ExpandLinkItems(kINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE,
|
|
|
- this->Target->GetLinkInterfaceDirectExcludeEntries(),
|
|
|
- config, headTarget, interfaceFor,
|
|
|
- LinkInterfaceField::HeadExclude, iface);
|
|
|
+ this->ExpandLinkItems(kINTERFACE_LINK_LIBRARIES,
|
|
|
+ this->Target->GetLinkInterfaceEntries(), config,
|
|
|
+ headTarget, interfaceFor, iface);
|
|
|
} else if (explicitLibrariesCMP0022OLD) {
|
|
|
// The interface libraries have been explicitly set in pre-CMP0022 style.
|
|
|
std::vector<BT<std::string>> entries;
|
|
|
entries.emplace_back(*explicitLibrariesCMP0022OLD);
|
|
|
this->ExpandLinkItems(linkIfacePropCMP0022OLD, cmMakeRange(entries),
|
|
|
- config, headTarget, interfaceFor,
|
|
|
- LinkInterfaceField::Libraries, iface);
|
|
|
+ config, headTarget, interfaceFor, iface);
|
|
|
}
|
|
|
|
|
|
// If the link interface is explicit, do not fall back to the link impl.
|
|
|
@@ -7285,8 +7262,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
|
|
|
cmLinkInterface ifaceNew;
|
|
|
this->ExpandLinkItems(kINTERFACE_LINK_LIBRARIES,
|
|
|
this->Target->GetLinkInterfaceEntries(), config,
|
|
|
- headTarget, interfaceFor,
|
|
|
- LinkInterfaceField::Libraries, ifaceNew);
|
|
|
+ headTarget, interfaceFor, ifaceNew);
|
|
|
if (ifaceNew.Libraries != iface.Libraries) {
|
|
|
std::string oldLibraries = cmJoin(impl->Libraries, ";");
|
|
|
std::string newLibraries = cmJoin(ifaceNew.Libraries, ";");
|
|
|
@@ -7426,17 +7402,8 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface(
|
|
|
iface.LibrariesDone = true;
|
|
|
iface.Multiplicity = info->Multiplicity;
|
|
|
cmExpandList(info->Languages, iface.Languages);
|
|
|
- this->ExpandLinkItems(kINTERFACE_LINK_LIBRARIES_DIRECT,
|
|
|
- cmMakeRange(info->LibrariesHeadInclude), config,
|
|
|
- headTarget, interfaceFor,
|
|
|
- LinkInterfaceField::HeadInclude, iface);
|
|
|
- this->ExpandLinkItems(kINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE,
|
|
|
- cmMakeRange(info->LibrariesHeadExclude), config,
|
|
|
- headTarget, interfaceFor,
|
|
|
- LinkInterfaceField::HeadExclude, iface);
|
|
|
this->ExpandLinkItems(info->LibrariesProp, cmMakeRange(info->Libraries),
|
|
|
- config, headTarget, interfaceFor,
|
|
|
- LinkInterfaceField::Libraries, iface);
|
|
|
+ config, headTarget, interfaceFor, iface);
|
|
|
std::vector<std::string> deps = cmExpandedList(info->SharedDeps);
|
|
|
LookupLinkItemScope scope{ this->LocalGenerator };
|
|
|
for (std::string const& dep : deps) {
|
|
|
@@ -7529,14 +7496,6 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- for (BT<std::string> const& entry :
|
|
|
- this->Target->GetLinkInterfaceDirectEntries()) {
|
|
|
- info.LibrariesHeadInclude.emplace_back(entry);
|
|
|
- }
|
|
|
- for (BT<std::string> const& entry :
|
|
|
- this->Target->GetLinkInterfaceDirectExcludeEntries()) {
|
|
|
- info.LibrariesHeadExclude.emplace_back(entry);
|
|
|
- }
|
|
|
if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
|
|
if (loc) {
|
|
|
info.LibName = *loc;
|
|
|
@@ -7970,112 +7929,6 @@ bool cmGeneratorTarget::IsNullImpliedByLinkLibraries(
|
|
|
return cm::contains(this->LinkImplicitNullProperties, p);
|
|
|
}
|
|
|
|
|
|
-namespace {
|
|
|
-class TransitiveLinkImpl
|
|
|
-{
|
|
|
- cmGeneratorTarget const* Self;
|
|
|
- std::string const& Config;
|
|
|
- cmLinkImplementation& Impl;
|
|
|
-
|
|
|
- std::set<cmLinkItem> Emitted;
|
|
|
- std::set<cmLinkItem> Excluded;
|
|
|
- std::unordered_set<cmGeneratorTarget const*> Followed;
|
|
|
-
|
|
|
- void Follow(cmGeneratorTarget const* target);
|
|
|
-
|
|
|
-public:
|
|
|
- TransitiveLinkImpl(cmGeneratorTarget const* self, std::string const& config,
|
|
|
- cmLinkImplementation& impl)
|
|
|
- : Self(self)
|
|
|
- , Config(config)
|
|
|
- , Impl(impl)
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
- void Compute();
|
|
|
-};
|
|
|
-
|
|
|
-void TransitiveLinkImpl::Follow(cmGeneratorTarget const* target)
|
|
|
-{
|
|
|
- if (!target || !this->Followed.insert(target).second ||
|
|
|
- target->GetPolicyStatusCMP0022() == cmPolicies::OLD ||
|
|
|
- target->GetPolicyStatusCMP0022() == cmPolicies::WARN) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // Get this target's usage requirements.
|
|
|
- cmLinkInterfaceLibraries const* iface = target->GetLinkInterfaceLibraries(
|
|
|
- this->Config, this->Self, LinkInterfaceFor::Usage);
|
|
|
- if (!iface) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (iface->HadContextSensitiveCondition) {
|
|
|
- this->Impl.HadContextSensitiveCondition = true;
|
|
|
- }
|
|
|
-
|
|
|
- // Process 'INTERFACE_LINK_LIBRARIES_DIRECT' usage requirements.
|
|
|
- for (cmLinkItem const& item : iface->HeadInclude) {
|
|
|
- // Inject direct dependencies from the item's usage requirements
|
|
|
- // before the item itself.
|
|
|
- this->Follow(item.Target);
|
|
|
-
|
|
|
- // Add the item itself, but at most once.
|
|
|
- if (this->Emitted.insert(item).second) {
|
|
|
- this->Impl.Libraries.emplace_back(item, /* checkCMP0027= */ false);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Follow transitive dependencies.
|
|
|
- for (cmLinkItem const& item : iface->Libraries) {
|
|
|
- this->Follow(item.Target);
|
|
|
- }
|
|
|
-
|
|
|
- // Record exclusions from 'INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE'
|
|
|
- // usage requirements.
|
|
|
- for (cmLinkItem const& item : iface->HeadExclude) {
|
|
|
- this->Excluded.insert(item);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void TransitiveLinkImpl::Compute()
|
|
|
-{
|
|
|
- // Save the original items and start with an empty list.
|
|
|
- std::vector<cmLinkImplItem> original = std::move(this->Impl.Libraries);
|
|
|
-
|
|
|
- // Avoid injecting any original items as usage requirements.
|
|
|
- // This gives LINK_LIBRARIES final control over the order
|
|
|
- // if it explicitly lists everything.
|
|
|
- this->Emitted.insert(original.cbegin(), original.cend());
|
|
|
-
|
|
|
- // Process each original item.
|
|
|
- for (cmLinkImplItem& item : original) {
|
|
|
- // Inject direct dependencies listed in 'INTERFACE_LINK_LIBRARIES_DIRECT'
|
|
|
- // usage requirements before the item itself.
|
|
|
- this->Follow(item.Target);
|
|
|
-
|
|
|
- // Add the item itself.
|
|
|
- this->Impl.Libraries.emplace_back(std::move(item));
|
|
|
- }
|
|
|
-
|
|
|
- // Remove items listed in 'INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE'
|
|
|
- // usage requirements found through any dependency above.
|
|
|
- this->Impl.Libraries.erase(
|
|
|
- std::remove_if(this->Impl.Libraries.begin(), this->Impl.Libraries.end(),
|
|
|
- [this](cmLinkImplItem const& item) {
|
|
|
- return this->Excluded.find(item) != this->Excluded.end();
|
|
|
- }),
|
|
|
- this->Impl.Libraries.end());
|
|
|
-}
|
|
|
-
|
|
|
-void ComputeLinkImplTransitive(cmGeneratorTarget const* self,
|
|
|
- std::string const& config,
|
|
|
- cmLinkImplementation& impl)
|
|
|
-{
|
|
|
- TransitiveLinkImpl transitiveLinkImpl(self, config, impl);
|
|
|
- transitiveLinkImpl.Compute();
|
|
|
-}
|
|
|
-}
|
|
|
-
|
|
|
void cmGeneratorTarget::ComputeLinkImplementationLibraries(
|
|
|
const std::string& config, cmOptionalLinkImplementation& impl,
|
|
|
cmGeneratorTarget const* head) const
|
|
|
@@ -8182,11 +8035,6 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
|
|
|
cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards);
|
|
|
}
|
|
|
|
|
|
- // Update the list of direct link dependencies from usage requirements.
|
|
|
- if (head == this) {
|
|
|
- ComputeLinkImplTransitive(this, config, impl);
|
|
|
- }
|
|
|
-
|
|
|
// Get the list of configurations considered to be DEBUG.
|
|
|
std::vector<std::string> debugConfigs =
|
|
|
this->Makefile->GetCMakeInstance()->GetDebugConfigs();
|