mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 14:08:35 +08:00
cmGeneratorTarget: Refactor link item lookup
Look up items individually so the call sites can do something with the result besides appending to a vector.
This commit is contained in:
@@ -6255,22 +6255,21 @@ bool cmGeneratorTarget::IsLinkLookupScope(std::string const& n,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGeneratorTarget::LookupLinkItems(std::vector<std::string> const& names,
|
cm::optional<cmLinkItem> cmGeneratorTarget::LookupLinkItem(
|
||||||
cmListFileBacktrace const& bt,
|
std::string const& n, cmListFileBacktrace const& bt) const
|
||||||
std::vector<cmLinkItem>& items) const
|
|
||||||
{
|
{
|
||||||
|
cm::optional<cmLinkItem> maybeItem;
|
||||||
cmLocalGenerator const* lg = this->LocalGenerator;
|
cmLocalGenerator const* lg = this->LocalGenerator;
|
||||||
for (std::string const& n : names) {
|
if (this->IsLinkLookupScope(n, lg)) {
|
||||||
if (this->IsLinkLookupScope(n, lg)) {
|
return maybeItem;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string name = this->CheckCMP0004(n);
|
|
||||||
if (name == this->GetName() || name.empty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
items.push_back(this->ResolveLinkItem(name, bt, lg));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string name = this->CheckCMP0004(n);
|
||||||
|
if (name == this->GetName() || name.empty()) {
|
||||||
|
return maybeItem;
|
||||||
|
}
|
||||||
|
maybeItem = this->ResolveLinkItem(name, bt, lg);
|
||||||
|
return maybeItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGeneratorTarget::ExpandLinkItems(
|
void cmGeneratorTarget::ExpandLinkItems(
|
||||||
@@ -6295,7 +6294,12 @@ void cmGeneratorTarget::ExpandLinkItems(
|
|||||||
cmExpandList(cge->Evaluate(this->LocalGenerator, config, headTarget,
|
cmExpandList(cge->Evaluate(this->LocalGenerator, config, headTarget,
|
||||||
&dagChecker, this, headTarget->LinkerLanguage),
|
&dagChecker, this, headTarget->LinkerLanguage),
|
||||||
libs);
|
libs);
|
||||||
this->LookupLinkItems(libs, cge->GetBacktrace(), items);
|
for (std::string const& lib : libs) {
|
||||||
|
if (cm::optional<cmLinkItem> maybeItem =
|
||||||
|
this->LookupLinkItem(lib, cge->GetBacktrace())) {
|
||||||
|
items.emplace_back(std::move(*maybeItem));
|
||||||
|
}
|
||||||
|
}
|
||||||
hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition();
|
hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition();
|
||||||
hadContextSensitiveCondition = cge->GetHadContextSensitiveCondition();
|
hadContextSensitiveCondition = cge->GetHadContextSensitiveCondition();
|
||||||
hadLinkLanguageSensitiveCondition =
|
hadLinkLanguageSensitiveCondition =
|
||||||
@@ -6903,7 +6907,12 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface(
|
|||||||
iface.HadContextSensitiveCondition,
|
iface.HadContextSensitiveCondition,
|
||||||
iface.HadLinkLanguageSensitiveCondition);
|
iface.HadLinkLanguageSensitiveCondition);
|
||||||
std::vector<std::string> deps = cmExpandedList(info->SharedDeps);
|
std::vector<std::string> deps = cmExpandedList(info->SharedDeps);
|
||||||
this->LookupLinkItems(deps, cmListFileBacktrace(), iface.SharedDeps);
|
for (std::string const& dep : deps) {
|
||||||
|
if (cm::optional<cmLinkItem> maybeItem =
|
||||||
|
this->LookupLinkItem(dep, cmListFileBacktrace())) {
|
||||||
|
iface.SharedDeps.emplace_back(std::move(*maybeItem));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &iface;
|
return &iface;
|
||||||
|
@@ -1039,9 +1039,8 @@ private:
|
|||||||
bool& hadHeadSensitiveCondition,
|
bool& hadHeadSensitiveCondition,
|
||||||
bool& hadContextSensitiveCondition,
|
bool& hadContextSensitiveCondition,
|
||||||
bool& hadLinkLanguageSensitiveCondition) const;
|
bool& hadLinkLanguageSensitiveCondition) const;
|
||||||
void LookupLinkItems(std::vector<std::string> const& names,
|
cm::optional<cmLinkItem> LookupLinkItem(std::string const& n,
|
||||||
cmListFileBacktrace const& bt,
|
cmListFileBacktrace const& bt) const;
|
||||||
std::vector<cmLinkItem>& items) const;
|
|
||||||
|
|
||||||
std::vector<BT<std::string>> GetSourceFilePaths(
|
std::vector<BT<std::string>> GetSourceFilePaths(
|
||||||
std::string const& config) const;
|
std::string const& config) const;
|
||||||
|
@@ -565,7 +565,7 @@ void TLL::AffectsProperty(std::string const& prop)
|
|||||||
if (!this->EncodeRemoteReference) {
|
if (!this->EncodeRemoteReference) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Add a wrapper to the expression to tell LookupLinkItems to look up
|
// Add a wrapper to the expression to tell LookupLinkItem to look up
|
||||||
// names in the caller's directory.
|
// names in the caller's directory.
|
||||||
if (this->Props.insert(prop).second) {
|
if (this->Props.insert(prop).second) {
|
||||||
this->Target->AppendProperty(prop, this->DirectoryId);
|
this->Target->AppendProperty(prop, this->DirectoryId);
|
||||||
|
Reference in New Issue
Block a user