summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-06-29 19:57:16 (GMT)
committerBrad King <brad.king@kitware.com>2021-06-29 20:52:12 (GMT)
commite27a76f1311ab4ad1be07df018ac748d4b725cea (patch)
treed52fc751827893cd9468f86460d2dc8994c94b5d /Source/cmGeneratorTarget.cxx
parentfb02657b6a4f66cfb1b1673c170136f07945eda2 (diff)
downloadCMake-e27a76f1311ab4ad1be07df018ac748d4b725cea.zip
CMake-e27a76f1311ab4ad1be07df018ac748d4b725cea.tar.gz
CMake-e27a76f1311ab4ad1be07df018ac748d4b725cea.tar.bz2
target_link_libraries: Restore transitive out-of-dir linking
Refactoring in commit 7f506b95a7 (cmGeneratorTarget: Refactor link item lookup, 2021-05-26, v3.21.0-rc1~103^2~4) accidentally dropped the persistent lookup scope tracking across multiple items that was added by commit f0e67da061 (target_link_libraries: Fix out-of-dir linking of a list of targets, 2020-01-14, v3.17.0-rc1~149^2). This broke a transitive out-of-dir linking case not covered by our test suite. Restore the scope tracking and add a test case. Fixes: #22363
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx14
1 files changed, 8 insertions, 6 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index f268c6c..f1ef130 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -6346,11 +6346,11 @@ bool cmGeneratorTarget::IsLinkLookupScope(std::string const& n,
}
cm::optional<cmLinkItem> cmGeneratorTarget::LookupLinkItem(
- std::string const& n, cmListFileBacktrace const& bt) const
+ std::string const& n, cmListFileBacktrace const& bt,
+ LookupLinkItemScope* scope) const
{
cm::optional<cmLinkItem> maybeItem;
- cmLocalGenerator const* lg = this->LocalGenerator;
- if (this->IsLinkLookupScope(n, lg)) {
+ if (this->IsLinkLookupScope(n, scope->LG)) {
return maybeItem;
}
@@ -6358,7 +6358,7 @@ cm::optional<cmLinkItem> cmGeneratorTarget::LookupLinkItem(
if (name == this->GetName() || name.empty()) {
return maybeItem;
}
- maybeItem = this->ResolveLinkItem(name, bt, lg);
+ maybeItem = this->ResolveLinkItem(name, bt, scope->LG);
return maybeItem;
}
@@ -6385,9 +6385,10 @@ void cmGeneratorTarget::ExpandLinkItems(
&dagChecker, this, headTarget->LinkerLanguage),
libs);
cmMakefile const* mf = this->LocalGenerator->GetMakefile();
+ LookupLinkItemScope scope{ this->LocalGenerator };
for (std::string const& lib : libs) {
if (cm::optional<cmLinkItem> maybeItem =
- this->LookupLinkItem(lib, cge->GetBacktrace())) {
+ this->LookupLinkItem(lib, cge->GetBacktrace(), &scope)) {
if (!maybeItem->Target) {
// Report explicitly linked object files separately.
std::string const& maybeObj = maybeItem->AsStr();
@@ -7089,9 +7090,10 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface(
iface.HadContextSensitiveCondition,
iface.HadLinkLanguageSensitiveCondition);
std::vector<std::string> deps = cmExpandedList(info->SharedDeps);
+ LookupLinkItemScope scope{ this->LocalGenerator };
for (std::string const& dep : deps) {
if (cm::optional<cmLinkItem> maybeItem =
- this->LookupLinkItem(dep, cmListFileBacktrace())) {
+ this->LookupLinkItem(dep, cmListFileBacktrace(), &scope)) {
iface.SharedDeps.emplace_back(std::move(*maybeItem));
}
}