diff options
author | Brad King <brad.king@kitware.com> | 2022-03-22 13:49:11 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-03-22 15:57:48 (GMT) |
commit | 41a6b4a53ba844ef986b0bc4efe8938b97eea810 (patch) | |
tree | dfb3e49b2b54cb24865ecf15d67cc3d8ba52c55f /Source | |
parent | 73337cb383a704664a47fd3fec84c8feaa303995 (diff) | |
download | CMake-41a6b4a53ba844ef986b0bc4efe8938b97eea810.zip CMake-41a6b4a53ba844ef986b0bc4efe8938b97eea810.tar.gz CMake-41a6b4a53ba844ef986b0bc4efe8938b97eea810.tar.bz2 |
INTERFACE_LINK_LIBRARIES_DIRECT: Honor link dependencies through LINK_ONLY
In commit f3ad061858 (Add usage requirements to update direct link
dependencies, 2022-01-12, v3.23.0-rc1~44^2), we evaluated the transitive
closure of `INTERFACE_LINK_LIBRARIES` as a non-linking usage requirement.
That left out `INTERFACE_LINK_LIBRARIES_DIRECT` link dependencies that
appear behind private dependencies of a static library, guarded by the
`$<LINK_ONLY:...>` generator expression. At the time, that decision was
intentional, in order to prevent arbitrary usage requirements from
leaking out of `PRIVATE` dependencies.
Since then, we've revised evaluation of `LINK_LIBRARIES` to distinguish
between collecting link dependencies and other usage requirements. Use
that information when following `INTERFACE_LINK_LIBRARIES` to collect
the matching kind of requirements from `INTERFACE_LINK_LIBRARIES_DIRECT`.
Fixes: #22496
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 17a521a..6c804b5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -8035,6 +8035,7 @@ class TransitiveLinkImpl { cmGeneratorTarget const* Self; std::string const& Config; + LinkInterfaceFor ImplFor; cmLinkImplementation& Impl; std::set<cmLinkItem> Emitted; @@ -8045,9 +8046,10 @@ class TransitiveLinkImpl public: TransitiveLinkImpl(cmGeneratorTarget const* self, std::string const& config, - cmLinkImplementation& impl) + LinkInterfaceFor implFor, cmLinkImplementation& impl) : Self(self) , Config(config) + , ImplFor(implFor) , Impl(impl) { } @@ -8064,8 +8066,8 @@ void TransitiveLinkImpl::Follow(cmGeneratorTarget const* target) } // Get this target's usage requirements. - cmLinkInterfaceLibraries const* iface = target->GetLinkInterfaceLibraries( - this->Config, this->Self, LinkInterfaceFor::Usage); + cmLinkInterfaceLibraries const* iface = + target->GetLinkInterfaceLibraries(this->Config, this->Self, this->ImplFor); if (!iface) { return; } @@ -8129,9 +8131,10 @@ void TransitiveLinkImpl::Compute() void ComputeLinkImplTransitive(cmGeneratorTarget const* self, std::string const& config, + LinkInterfaceFor implFor, cmLinkImplementation& impl) { - TransitiveLinkImpl transitiveLinkImpl(self, config, impl); + TransitiveLinkImpl transitiveLinkImpl(self, config, implFor, impl); transitiveLinkImpl.Compute(); } } @@ -8140,7 +8143,6 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( const std::string& config, cmOptionalLinkImplementation& impl, cmGeneratorTarget const* head, LinkInterfaceFor implFor) const { - static_cast<void>(implFor); cmLocalGenerator const* lg = this->LocalGenerator; cmMakefile const* mf = lg->GetMakefile(); cmBTStringRange entryRange = this->Target->GetLinkImplementationEntries(); @@ -8245,7 +8247,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( // Update the list of direct link dependencies from usage requirements. if (head == this) { - ComputeLinkImplTransitive(this, config, impl); + ComputeLinkImplTransitive(this, config, implFor, impl); } // Get the list of configurations considered to be DEBUG. |