cmLinkItem: Port to cmGeneratorTarget.

This commit is contained in:
Stephen Kelly 2015-10-08 01:18:42 +02:00
parent bf2d061ad3
commit ceb35b63a7
5 changed files with 25 additions and 38 deletions

View File

@ -320,8 +320,7 @@ int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
int index = lei->second;
LinkEntry& entry = this->EntryList[index];
entry.Item = item;
entry.Target =
item.Target ? this->GlobalGenerator->GetGeneratorTarget(item.Target) : 0;
entry.Target = item.Target;
entry.IsFlag = (!entry.Target && item[0] == '-' && item[1] != 'l' &&
item.substr(0, 10) != "-framework");
@ -443,9 +442,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
// Initialize the item entry.
LinkEntry& entry = this->EntryList[lei->second];
entry.Item = dep.Item;
entry.Target =
dep.Item.Target ?
this->GlobalGenerator->GetGeneratorTarget(dep.Item.Target) : 0;
entry.Target = dep.Item.Target;
// This item was added specifically because it is a dependent
// shared library. It may get special treatment
@ -983,7 +980,6 @@ void cmComputeLinkDepends::CheckWrongConfigItem(cmLinkItem const& item)
// directories.
if(item.Target && !item.Target->IsImported())
{
this->OldWrongConfigItems.insert(
this->GlobalGenerator->GetGeneratorTarget(item.Target));
this->OldWrongConfigItems.insert(item.Target);
}
}

View File

@ -319,22 +319,20 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
std::set<std::string> &emitted)
{
cmGeneratorTarget const* depender = this->Targets[depender_index];
cmTarget const* dependee = dependee_name.Target;
cmGeneratorTarget const* dependee = dependee_name.Target;
// Skip targets that will not really be linked. This is probably a
// name conflict between an external library and an executable
// within the project.
if(dependee &&
dependee->GetType() == cmTarget::EXECUTABLE &&
!dependee->IsExecutableWithExports())
!dependee->Target->IsExecutableWithExports())
{
dependee = 0;
}
if(dependee)
{
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(dependee);
this->AddInterfaceDepends(depender_index, gt, "", emitted);
this->AddInterfaceDepends(depender_index, dependee, "", emitted);
std::vector<std::string> configs;
depender->Makefile->GetConfigurations(configs);
for (std::vector<std::string>::const_iterator it = configs.begin();
@ -342,7 +340,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
{
// A target should not depend on itself.
emitted.insert(depender->GetName());
this->AddInterfaceDepends(depender_index, gt, *it, emitted);
this->AddInterfaceDepends(depender_index, dependee, *it, emitted);
}
}
}
@ -356,7 +354,7 @@ void cmComputeTargetDepends::AddTargetDepend(
cmGeneratorTarget const* depender = this->Targets[depender_index];
// Check the target's makefile first.
cmTarget const* dependee = dependee_name.Target;
cmGeneratorTarget const* dependee = dependee_name.Target;
if(!dependee && !linking &&
(depender->GetType() != cmTarget::GLOBAL_TARGET))
@ -403,16 +401,14 @@ void cmComputeTargetDepends::AddTargetDepend(
// within the project.
if(linking && dependee &&
dependee->GetType() == cmTarget::EXECUTABLE &&
!dependee->IsExecutableWithExports())
!dependee->Target->IsExecutableWithExports())
{
dependee = 0;
}
if(dependee)
{
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(dependee);
this->AddTargetDepend(depender_index, gt, linking);
this->AddTargetDepend(depender_index, dependee, linking);
}
}
@ -430,11 +426,9 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
for(std::set<cmLinkItem>::const_iterator i = utils.begin();
i != utils.end(); ++i)
{
if(cmTarget const* transitive_dependee = i->Target)
if(cmGeneratorTarget const* transitive_dependee = i->Target)
{
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(transitive_dependee);
this->AddTargetDepend(depender_index, gt, false);
this->AddTargetDepend(depender_index, transitive_dependee, false);
}
}
}

View File

@ -846,7 +846,7 @@ getLinkedTargetsContent(
// Broken code can have a target in its own link interface.
// Don't follow such link interface entries so as not to create a
// self-referencing loop.
if (it->Target && it->Target != target)
if (it->Target && it->Target->Target != target)
{
depString +=
sep + "$<TARGET_PROPERTY:" +

View File

@ -773,8 +773,10 @@ std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const
for(std::set<std::string>::const_iterator i = utilities.begin();
i != utilities.end(); ++i)
{
this->UtilityItems.insert(
cmLinkItem(*i, this->Makefile->FindTargetToUse(*i)));
cmTarget* tgt = this->Makefile->FindTargetToUse(*i);
cmGeneratorTarget* gt = tgt ? this->GlobalGenerator
->GetGeneratorTarget(tgt) : 0;
this->UtilityItems.insert(cmLinkItem(*i, gt));
}
}
return this->UtilityItems;
@ -1728,15 +1730,12 @@ public:
}
return;
}
if(!this->Visited.insert(item.Target).second)
if(!this->Visited.insert(item.Target->Target).second)
{
return;
}
cmGeneratorTarget* gtgt =
this->Target->GetLocalGenerator()->GetGlobalGenerator()
->GetGeneratorTarget(item.Target);
cmLinkInterface const* iface =
gtgt->GetLinkInterface(this->Config, this->HeadTarget);
item.Target->GetLinkInterface(this->Config, this->HeadTarget);
if(!iface) { return; }
for(std::vector<std::string>::const_iterator
@ -2070,12 +2069,11 @@ void processILibs(const std::string& config,
std::vector<cmTarget const*>& tgts,
std::set<cmTarget const*>& emitted)
{
if (item.Target && emitted.insert(item.Target).second)
if (item.Target && emitted.insert(item.Target->Target).second)
{
tgts.push_back(item.Target);
cmGeneratorTarget* gt = gg->GetGeneratorTarget(item.Target);
tgts.push_back(item.Target->Target);
if(cmLinkInterfaceLibraries const* iface =
gt->GetLinkInterfaceLibraries(config, headTarget, true))
item.Target->GetLinkInterfaceLibraries(config, headTarget, true))
{
for(std::vector<cmLinkItem>::const_iterator
it = iface->Libraries.begin();

View File

@ -16,7 +16,6 @@
#include "cmListFileCache.h"
class cmGeneratorTarget;
class cmTarget;
// Basic information about each link item.
class cmLinkItem: public std::string
@ -25,9 +24,9 @@ class cmLinkItem: public std::string
public:
cmLinkItem(): std_string(), Target(0) {}
cmLinkItem(const std_string& n,
cmTarget const* t): std_string(n), Target(t) {}
cmGeneratorTarget const* t): std_string(n), Target(t) {}
cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {}
cmTarget const* Target;
cmGeneratorTarget const* Target;
};
class cmLinkImplItem: public cmLinkItem
@ -35,7 +34,7 @@ class cmLinkImplItem: public cmLinkItem
public:
cmLinkImplItem(): cmLinkItem(), Backtrace(), FromGenex(false) {}
cmLinkImplItem(std::string const& n,
cmTarget const* t,
cmGeneratorTarget const* t,
cmListFileBacktrace const& bt,
bool fromGenex):
cmLinkItem(n, t), Backtrace(bt), FromGenex(fromGenex) {}