mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
cmGeneratorTarget: Factor target name resolution out of link item resolution
This commit is contained in:
@@ -5645,24 +5645,38 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmGeneratorTarget::TargetOrString cmGeneratorTarget::ResolveTargetReference(
|
||||||
|
std::string const& name) const
|
||||||
|
{
|
||||||
|
TargetOrString resolved;
|
||||||
|
|
||||||
|
if (cmGeneratorTarget* tgt =
|
||||||
|
this->LocalGenerator->FindGeneratorTargetToUse(name)) {
|
||||||
|
resolved.Target = tgt;
|
||||||
|
} else {
|
||||||
|
resolved.String = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolved;
|
||||||
|
}
|
||||||
|
|
||||||
cmLinkItem cmGeneratorTarget::ResolveLinkItem(std::string const& name) const
|
cmLinkItem cmGeneratorTarget::ResolveLinkItem(std::string const& name) const
|
||||||
{
|
{
|
||||||
cmGeneratorTarget* tgt =
|
TargetOrString resolved = this->ResolveTargetReference(name);
|
||||||
this->LocalGenerator->FindGeneratorTargetToUse(name);
|
|
||||||
|
if (!resolved.Target) {
|
||||||
|
return cmLinkItem(resolved.String);
|
||||||
|
}
|
||||||
|
|
||||||
// Skip targets that will not really be linked. This is probably a
|
// Skip targets that will not really be linked. This is probably a
|
||||||
// name conflict between an external library and an executable
|
// name conflict between an external library and an executable
|
||||||
// within the project.
|
// within the project.
|
||||||
if (tgt && tgt->GetType() == cmStateEnums::EXECUTABLE &&
|
if (resolved.Target->GetType() == cmStateEnums::EXECUTABLE &&
|
||||||
!tgt->IsExecutableWithExports()) {
|
!resolved.Target->IsExecutableWithExports()) {
|
||||||
tgt = nullptr;
|
return cmLinkItem(resolved.Target->GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tgt) {
|
return cmLinkItem(resolved.Target);
|
||||||
return cmLinkItem(tgt);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmLinkItem(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
|
std::string cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
|
||||||
|
|||||||
@@ -357,6 +357,13 @@ public:
|
|||||||
cmOptionalLinkImplementation& impl,
|
cmOptionalLinkImplementation& impl,
|
||||||
const cmGeneratorTarget* head) const;
|
const cmGeneratorTarget* head) const;
|
||||||
|
|
||||||
|
struct TargetOrString
|
||||||
|
{
|
||||||
|
std::string String;
|
||||||
|
cmGeneratorTarget* Target = nullptr;
|
||||||
|
};
|
||||||
|
TargetOrString ResolveTargetReference(std::string const& name) const;
|
||||||
|
|
||||||
cmLinkItem ResolveLinkItem(std::string const& name) const;
|
cmLinkItem ResolveLinkItem(std::string const& name) const;
|
||||||
|
|
||||||
// Compute the set of languages compiled by the target. This is
|
// Compute the set of languages compiled by the target. This is
|
||||||
|
|||||||
Reference in New Issue
Block a user