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

View File

@ -319,22 +319,20 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
std::set<std::string> &emitted) std::set<std::string> &emitted)
{ {
cmGeneratorTarget const* depender = this->Targets[depender_index]; 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 // 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(dependee && if(dependee &&
dependee->GetType() == cmTarget::EXECUTABLE && dependee->GetType() == cmTarget::EXECUTABLE &&
!dependee->IsExecutableWithExports()) !dependee->Target->IsExecutableWithExports())
{ {
dependee = 0; dependee = 0;
} }
if(dependee) if(dependee)
{ {
cmGeneratorTarget* gt = this->AddInterfaceDepends(depender_index, dependee, "", emitted);
this->GlobalGenerator->GetGeneratorTarget(dependee);
this->AddInterfaceDepends(depender_index, gt, "", emitted);
std::vector<std::string> configs; std::vector<std::string> configs;
depender->Makefile->GetConfigurations(configs); depender->Makefile->GetConfigurations(configs);
for (std::vector<std::string>::const_iterator it = configs.begin(); 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. // A target should not depend on itself.
emitted.insert(depender->GetName()); 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]; cmGeneratorTarget const* depender = this->Targets[depender_index];
// Check the target's makefile first. // Check the target's makefile first.
cmTarget const* dependee = dependee_name.Target; cmGeneratorTarget const* dependee = dependee_name.Target;
if(!dependee && !linking && if(!dependee && !linking &&
(depender->GetType() != cmTarget::GLOBAL_TARGET)) (depender->GetType() != cmTarget::GLOBAL_TARGET))
@ -403,16 +401,14 @@ void cmComputeTargetDepends::AddTargetDepend(
// within the project. // within the project.
if(linking && dependee && if(linking && dependee &&
dependee->GetType() == cmTarget::EXECUTABLE && dependee->GetType() == cmTarget::EXECUTABLE &&
!dependee->IsExecutableWithExports()) !dependee->Target->IsExecutableWithExports())
{ {
dependee = 0; dependee = 0;
} }
if(dependee) if(dependee)
{ {
cmGeneratorTarget* gt = this->AddTargetDepend(depender_index, dependee, linking);
this->GlobalGenerator->GetGeneratorTarget(dependee);
this->AddTargetDepend(depender_index, gt, linking);
} }
} }
@ -430,11 +426,9 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
for(std::set<cmLinkItem>::const_iterator i = utils.begin(); for(std::set<cmLinkItem>::const_iterator i = utils.begin();
i != utils.end(); ++i) i != utils.end(); ++i)
{ {
if(cmTarget const* transitive_dependee = i->Target) if(cmGeneratorTarget const* transitive_dependee = i->Target)
{ {
cmGeneratorTarget* gt = this->AddTargetDepend(depender_index, transitive_dependee, false);
this->GlobalGenerator->GetGeneratorTarget(transitive_dependee);
this->AddTargetDepend(depender_index, gt, false);
} }
} }
} }

View File

@ -846,7 +846,7 @@ getLinkedTargetsContent(
// Broken code can have a target in its own link interface. // Broken code can have a target in its own link interface.
// Don't follow such link interface entries so as not to create a // Don't follow such link interface entries so as not to create a
// self-referencing loop. // self-referencing loop.
if (it->Target && it->Target != target) if (it->Target && it->Target->Target != target)
{ {
depString += depString +=
sep + "$<TARGET_PROPERTY:" + 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(); for(std::set<std::string>::const_iterator i = utilities.begin();
i != utilities.end(); ++i) i != utilities.end(); ++i)
{ {
this->UtilityItems.insert( cmTarget* tgt = this->Makefile->FindTargetToUse(*i);
cmLinkItem(*i, this->Makefile->FindTargetToUse(*i))); cmGeneratorTarget* gt = tgt ? this->GlobalGenerator
->GetGeneratorTarget(tgt) : 0;
this->UtilityItems.insert(cmLinkItem(*i, gt));
} }
} }
return this->UtilityItems; return this->UtilityItems;
@ -1728,15 +1730,12 @@ public:
} }
return; return;
} }
if(!this->Visited.insert(item.Target).second) if(!this->Visited.insert(item.Target->Target).second)
{ {
return; return;
} }
cmGeneratorTarget* gtgt =
this->Target->GetLocalGenerator()->GetGlobalGenerator()
->GetGeneratorTarget(item.Target);
cmLinkInterface const* iface = cmLinkInterface const* iface =
gtgt->GetLinkInterface(this->Config, this->HeadTarget); item.Target->GetLinkInterface(this->Config, this->HeadTarget);
if(!iface) { return; } if(!iface) { return; }
for(std::vector<std::string>::const_iterator for(std::vector<std::string>::const_iterator
@ -2070,12 +2069,11 @@ void processILibs(const std::string& config,
std::vector<cmTarget const*>& tgts, std::vector<cmTarget const*>& tgts,
std::set<cmTarget const*>& emitted) 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); tgts.push_back(item.Target->Target);
cmGeneratorTarget* gt = gg->GetGeneratorTarget(item.Target);
if(cmLinkInterfaceLibraries const* iface = if(cmLinkInterfaceLibraries const* iface =
gt->GetLinkInterfaceLibraries(config, headTarget, true)) item.Target->GetLinkInterfaceLibraries(config, headTarget, true))
{ {
for(std::vector<cmLinkItem>::const_iterator for(std::vector<cmLinkItem>::const_iterator
it = iface->Libraries.begin(); it = iface->Libraries.begin();

View File

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