From 22d5427aa60973b387ade94dc8e65fca8d4de413 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 12 Jan 2022 16:45:11 -0500 Subject: cmGeneratorTarget: Add LookupLinkItem option to consider own target name --- Source/cmGeneratorTarget.cxx | 13 +++++++------ Source/cmGeneratorTarget.h | 8 +++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 5ec6832..8a17476 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -6645,7 +6645,7 @@ bool cmGeneratorTarget::IsLinkLookupScope(std::string const& n, cm::optional cmGeneratorTarget::LookupLinkItem( std::string const& n, cmListFileBacktrace const& bt, - LookupLinkItemScope* scope) const + LookupLinkItemScope* scope, LookupSelf lookupSelf) const { cm::optional maybeItem; if (this->IsLinkLookupScope(n, scope->LG)) { @@ -6653,7 +6653,8 @@ cm::optional cmGeneratorTarget::LookupLinkItem( } std::string name = this->CheckCMP0004(n); - if (name == this->GetName() || name.empty()) { + if (name.empty() || + (lookupSelf == LookupSelf::No && name == this->GetName())) { return maybeItem; } maybeItem = this->ResolveLinkItem(BT(name, bt), scope->LG); @@ -6688,8 +6689,8 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop, cge->Evaluate(this->LocalGenerator, config, headTarget, &dagChecker, this, headTarget->LinkerLanguage)); for (std::string const& lib : libs) { - if (cm::optional maybeItem = - this->LookupLinkItem(lib, cge->GetBacktrace(), &scope)) { + if (cm::optional maybeItem = this->LookupLinkItem( + lib, cge->GetBacktrace(), &scope, LookupSelf::No)) { cmLinkItem item = std::move(*maybeItem); if (!item.Target) { @@ -7400,8 +7401,8 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface( std::vector deps = cmExpandedList(info->SharedDeps); LookupLinkItemScope scope{ this->LocalGenerator }; for (std::string const& dep : deps) { - if (cm::optional maybeItem = - this->LookupLinkItem(dep, cmListFileBacktrace(), &scope)) { + if (cm::optional maybeItem = this->LookupLinkItem( + dep, cmListFileBacktrace(), &scope, LookupSelf::No)) { iface.SharedDeps.emplace_back(std::move(*maybeItem)); } } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8134087..f36e2be 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -1073,9 +1073,15 @@ private: { cmLocalGenerator const* LG; }; + enum class LookupSelf + { + No, + Yes, + }; cm::optional LookupLinkItem(std::string const& n, cmListFileBacktrace const& bt, - LookupLinkItemScope* scope) const; + LookupLinkItemScope* scope, + LookupSelf lookupSelf) const; std::vector> GetSourceFilePaths( std::string const& config) const; -- cgit v0.12