diff options
author | Brad King <brad.king@kitware.com> | 2022-03-22 15:56:32 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-03-22 15:56:43 (GMT) |
commit | 2aad4cef979bd5174f067424a117fac765e3da34 (patch) | |
tree | 10ef6e88800579c6f6978c92b2f59af7f0bd025d /Source | |
parent | 25c31f19559732056fe11d472ad85ef4840eefc8 (diff) | |
parent | 687a91967f4cb02943421802e7929a6582cec63a (diff) | |
download | CMake-2aad4cef979bd5174f067424a117fac765e3da34.zip CMake-2aad4cef979bd5174f067424a117fac765e3da34.tar.gz CMake-2aad4cef979bd5174f067424a117fac765e3da34.tar.bz2 |
Merge topic 'revert-link-interface-direct-for-3.23' into release-3.23
687a91967f Revert INTERFACE_LINK_LIBRARIES_DIRECT feature for 3.23 branch
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7098
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExportFileGenerator.cxx | 27 | ||||
-rw-r--r-- | Source/cmExportTryCompileFileGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionDAGChecker.cxx | 2 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 180 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 10 | ||||
-rw-r--r-- | Source/cmLinkItem.h | 6 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 59 | ||||
-rw-r--r-- | Source/cmTarget.h | 2 |
8 files changed, 25 insertions, 263 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index b46b933..ed1e4cb 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExportFileGenerator.h" -#include <array> #include <cassert> #include <cstring> #include <sstream> @@ -176,24 +175,18 @@ bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty( if (!target->IsLinkable()) { return false; } - static const std::array<std::string, 3> linkIfaceProps = { - { "INTERFACE_LINK_LIBRARIES", "INTERFACE_LINK_LIBRARIES_DIRECT", - "INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE" } - }; - bool hadINTERFACE_LINK_LIBRARIES = false; - for (std::string const& linkIfaceProp : linkIfaceProps) { - if (cmValue input = target->GetProperty(linkIfaceProp)) { - std::string prepro = - cmGeneratorExpression::Preprocess(*input, preprocessRule); - if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions( - prepro, target, missingTargets, ReplaceFreeTargets); - properties[linkIfaceProp] = prepro; - hadINTERFACE_LINK_LIBRARIES = true; - } + cmValue input = target->GetProperty("INTERFACE_LINK_LIBRARIES"); + if (input) { + std::string prepro = + cmGeneratorExpression::Preprocess(*input, preprocessRule); + if (!prepro.empty()) { + this->ResolveTargetsInGeneratorExpressions( + prepro, target, missingTargets, ReplaceFreeTargets); + properties["INTERFACE_LINK_LIBRARIES"] = prepro; + return true; } } - return hadINTERFACE_LINK_LIBRARIES; + return false; } static bool isSubDirectory(std::string const& a, std::string const& b) diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index e98aa05..db9b05b 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -111,8 +111,6 @@ void cmExportTryCompileFileGenerator::PopulateProperties( std::vector<std::string> props = target->GetPropertyKeys(); // Include special properties that might be relevant here. props.emplace_back("INTERFACE_LINK_LIBRARIES"); - props.emplace_back("INTERFACE_LINK_LIBRARIES_DIRECT"); - props.emplace_back("INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE"); for (std::string const& p : props) { cmValue v = target->GetProperty(p); if (!v) { diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index d4b02a5..187db73 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -189,8 +189,6 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries( } return prop == "LINK_LIBRARIES"_s || prop == "INTERFACE_LINK_LIBRARIES"_s || - prop == "INTERFACE_LINK_LIBRARIES_DIRECT"_s || - prop == "INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE"_s || prop == "LINK_INTERFACE_LIBRARIES"_s || prop == "IMPORTED_LINK_INTERFACE_LIBRARIES"_s || cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES_") || diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 63cf2ec..a8bc91c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -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(); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 45639c0..7cf1720 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -1006,8 +1006,6 @@ private: std::string Languages; std::string LibrariesProp; std::vector<BT<std::string>> Libraries; - std::vector<BT<std::string>> LibrariesHeadInclude; - std::vector<BT<std::string>> LibrariesHeadExclude; std::string SharedDeps; }; @@ -1068,16 +1066,10 @@ private: bool IsLinkLookupScope(std::string const& n, cmLocalGenerator const*& lg) const; - enum class LinkInterfaceField - { - Libraries, - HeadExclude, - HeadInclude, - }; void ExpandLinkItems(std::string const& prop, cmBTStringRange entries, std::string const& config, const cmGeneratorTarget* headTarget, - LinkInterfaceFor interfaceFor, LinkInterfaceField field, + LinkInterfaceFor interfaceFor, cmLinkInterface& iface) const; struct LookupLinkItemScope diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index 262728b..e715659 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -70,12 +70,6 @@ struct cmLinkInterfaceLibraries // Object files listed in the interface. std::vector<cmLinkItem> Objects; - // Items to be included as if directly linked by the head target. - std::vector<cmLinkItem> HeadInclude; - - // Items to be excluded from direct linking by the head target. - std::vector<cmLinkItem> HeadExclude; - // Whether the list depends on a genex referencing the head target. bool HadHeadSensitiveCondition = false; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6059055..e1a9667 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -203,8 +203,6 @@ public: std::vector<BT<std::string>> LinkDirectoriesEntries; std::vector<BT<std::string>> LinkImplementationPropertyEntries; std::vector<BT<std::string>> LinkInterfacePropertyEntries; - std::vector<BT<std::string>> LinkInterfaceDirectPropertyEntries; - std::vector<BT<std::string>> LinkInterfaceDirectExcludePropertyEntries; std::vector<BT<std::string>> HeaderSetsEntries; std::vector<BT<std::string>> InterfaceHeaderSetsEntries; std::vector<std::pair<cmTarget::TLLSignature, cmListFileContext>> @@ -1144,16 +1142,6 @@ cmBTStringRange cmTarget::GetLinkInterfaceEntries() const return cmMakeRange(this->impl->LinkInterfacePropertyEntries); } -cmBTStringRange cmTarget::GetLinkInterfaceDirectEntries() const -{ - return cmMakeRange(this->impl->LinkInterfaceDirectPropertyEntries); -} - -cmBTStringRange cmTarget::GetLinkInterfaceDirectExcludeEntries() const -{ - return cmMakeRange(this->impl->LinkInterfaceDirectExcludePropertyEntries); -} - cmBTStringRange cmTarget::GetHeaderSetsEntries() const { return cmMakeRange(this->impl->HeaderSetsEntries); @@ -1198,8 +1186,6 @@ MAKE_PROP(HEADER_SET); MAKE_PROP(HEADER_SETS); MAKE_PROP(INTERFACE_HEADER_SETS); MAKE_PROP(INTERFACE_LINK_LIBRARIES); -MAKE_PROP(INTERFACE_LINK_LIBRARIES_DIRECT); -MAKE_PROP(INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE); #undef MAKE_PROP } @@ -1331,19 +1317,6 @@ void cmTarget::StoreProperty(const std::string& prop, ValueType value) cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace(); this->impl->LinkInterfacePropertyEntries.emplace_back(value, lfbt); } - } else if (prop == propINTERFACE_LINK_LIBRARIES_DIRECT) { - this->impl->LinkInterfaceDirectPropertyEntries.clear(); - if (value) { - cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace(); - this->impl->LinkInterfaceDirectPropertyEntries.emplace_back(value, lfbt); - } - } else if (prop == propINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE) { - this->impl->LinkInterfaceDirectExcludePropertyEntries.clear(); - if (value) { - cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace(); - this->impl->LinkInterfaceDirectExcludePropertyEntries.emplace_back(value, - lfbt); - } } else if (prop == propSOURCES) { this->impl->SourceEntries.clear(); if (value) { @@ -1602,17 +1575,6 @@ void cmTarget::AppendProperty(const std::string& prop, cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace(); this->impl->LinkInterfacePropertyEntries.emplace_back(value, lfbt); } - } else if (prop == propINTERFACE_LINK_LIBRARIES_DIRECT) { - if (!value.empty()) { - cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace(); - this->impl->LinkInterfaceDirectPropertyEntries.emplace_back(value, lfbt); - } - } else if (prop == propINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE) { - if (!value.empty()) { - cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace(); - this->impl->LinkInterfaceDirectExcludePropertyEntries.emplace_back(value, - lfbt); - } } else if (prop == "SOURCES") { cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace(); this->impl->SourceEntries.emplace_back(value, lfbt); @@ -1923,8 +1885,6 @@ cmValue cmTarget::GetProperty(const std::string& prop) const propHEADER_SETS, propINTERFACE_HEADER_SETS, propINTERFACE_LINK_LIBRARIES, - propINTERFACE_LINK_LIBRARIES_DIRECT, - propINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE, }; if (specialProps.count(prop)) { if (prop == propC_STANDARD || prop == propCXX_STANDARD || @@ -1954,25 +1914,6 @@ cmValue cmTarget::GetProperty(const std::string& prop) const output = cmJoin(this->impl->LinkInterfacePropertyEntries, ";"); return cmValue(output); } - if (prop == propINTERFACE_LINK_LIBRARIES_DIRECT) { - if (this->impl->LinkInterfaceDirectPropertyEntries.empty()) { - return nullptr; - } - - static std::string output; - output = cmJoin(this->impl->LinkInterfaceDirectPropertyEntries, ";"); - return cmValue(output); - } - if (prop == propINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE) { - if (this->impl->LinkInterfaceDirectExcludePropertyEntries.empty()) { - return nullptr; - } - - static std::string output; - output = - cmJoin(this->impl->LinkInterfaceDirectExcludePropertyEntries, ";"); - return cmValue(output); - } // the type property returns what type the target is if (prop == propTYPE) { return cmValue(cmState::GetTargetTypeName(this->GetType())); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 0cdd2fc..1bbd0b0 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -269,8 +269,6 @@ public: cmBTStringRange GetLinkImplementationEntries() const; cmBTStringRange GetLinkInterfaceEntries() const; - cmBTStringRange GetLinkInterfaceDirectEntries() const; - cmBTStringRange GetLinkInterfaceDirectExcludeEntries() const; cmBTStringRange GetHeaderSetsEntries() const; |