cmComputeTargetDepends: Change API to use cmGeneratorTarget.

This commit is contained in:
Stephen Kelly 2015-06-06 13:08:17 +02:00
parent 7e3ac12df4
commit faec4e611d
16 changed files with 132 additions and 108 deletions

View File

@ -147,12 +147,12 @@ bool cmComputeTargetDepends::Compute()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmComputeTargetDepends::GetTargetDirectDepends(cmTarget const* t, cmComputeTargetDepends::GetTargetDirectDepends(cmGeneratorTarget const* t,
cmTargetDependSet& deps) cmTargetDependSet& deps)
{ {
// Lookup the index for this target. All targets should be known by // Lookup the index for this target. All targets should be known by
// this point. // this point.
std::map<cmTarget const*, int>::const_iterator tii std::map<cmGeneratorTarget const*, int>::const_iterator tii
= this->TargetIndex.find(t); = this->TargetIndex.find(t);
assert(tii != this->TargetIndex.end()); assert(tii != this->TargetIndex.end());
int i = tii->second; int i = tii->second;
@ -161,7 +161,7 @@ cmComputeTargetDepends::GetTargetDirectDepends(cmTarget const* t,
EdgeList const& nl = this->FinalGraph[i]; EdgeList const& nl = this->FinalGraph[i];
for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
{ {
cmTarget const* dep = this->Targets[*ni]; cmGeneratorTarget const* dep = this->Targets[*ni];
cmTargetDependSet::iterator di = deps.insert(dep).first; cmTargetDependSet::iterator di = deps.insert(dep).first;
di->SetType(ni->IsStrong()); di->SetType(ni->IsStrong());
} }
@ -180,9 +180,11 @@ void cmComputeTargetDepends::CollectTargets()
ti != targets.end(); ++ti) ti != targets.end(); ++ti)
{ {
cmTarget const* target = &ti->second; cmTarget const* target = &ti->second;
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(target);
int index = static_cast<int>(this->Targets.size()); int index = static_cast<int>(this->Targets.size());
this->TargetIndex[target] = index; this->TargetIndex[gt] = index;
this->Targets.push_back(target); this->Targets.push_back(gt);
} }
} }
} }
@ -204,7 +206,7 @@ void cmComputeTargetDepends::CollectDepends()
void cmComputeTargetDepends::CollectTargetDepends(int depender_index) void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
{ {
// Get the depender. // Get the depender.
cmTarget const* depender = this->Targets[depender_index]; cmGeneratorTarget const* depender = this->Targets[depender_index];
if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) if (depender->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
return; return;
@ -216,10 +218,9 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// deal with config-specific dependencies. // deal with config-specific dependencies.
{ {
std::set<std::string> emitted; std::set<std::string> emitted;
cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(depender);
std::vector<std::string> configs; std::vector<std::string> configs;
depender->GetMakefile()->GetConfigurations(configs); depender->Makefile->GetConfigurations(configs);
if (configs.empty()) if (configs.empty())
{ {
configs.push_back(""); configs.push_back("");
@ -228,7 +229,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
it != configs.end(); ++it) it != configs.end(); ++it)
{ {
std::vector<cmSourceFile const*> objectFiles; std::vector<cmSourceFile const*> objectFiles;
gt->GetExternalObjects(objectFiles, *it); depender->GetExternalObjects(objectFiles, *it);
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
oi = objectFiles.begin(); oi != objectFiles.end(); ++oi) oi = objectFiles.begin(); oi != objectFiles.end(); ++oi)
{ {
@ -244,15 +245,15 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
->IssueMessage(cmake::FATAL_ERROR, ->IssueMessage(cmake::FATAL_ERROR,
"Only executables and non-OBJECT libraries may " "Only executables and non-OBJECT libraries may "
"reference target objects.", "reference target objects.",
depender->GetBacktrace()); depender->Target->GetBacktrace());
return; return;
} }
const_cast<cmTarget*>(depender)->AddUtility(objLib); const_cast<cmGeneratorTarget*>(depender)->Target->AddUtility(objLib);
} }
} }
cmTarget::LinkImplementation const* impl = cmTarget::LinkImplementation const* impl =
depender->GetLinkImplementation(*it); depender->Target->GetLinkImplementation(*it);
// A target should not depend on itself. // A target should not depend on itself.
emitted.insert(depender->GetName()); emitted.insert(depender->GetName());
@ -272,7 +273,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// Loop over all utility dependencies. // Loop over all utility dependencies.
{ {
std::set<cmLinkItem> const& tutils = depender->GetUtilityItems(); std::set<cmLinkItem> const& tutils = depender->Target->GetUtilityItems();
std::set<std::string> emitted; std::set<std::string> emitted;
// A target should not depend on itself. // A target should not depend on itself.
emitted.insert(depender->GetName()); emitted.insert(depender->GetName());
@ -290,13 +291,14 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
cmTarget const* dependee, const cmGeneratorTarget* dependee,
const std::string& config, const std::string& config,
std::set<std::string> &emitted) std::set<std::string> &emitted)
{ {
cmTarget const* depender = this->Targets[depender_index]; cmGeneratorTarget const* depender = this->Targets[depender_index];
if(cmTarget::LinkInterface const* iface = if(cmTarget::LinkInterface const* iface =
dependee->GetLinkInterface(config, depender)) dependee->Target->GetLinkInterface(config,
depender->Target))
{ {
for(std::vector<cmLinkItem>::const_iterator for(std::vector<cmLinkItem>::const_iterator
lib = iface->Libraries.begin(); lib = iface->Libraries.begin();
@ -317,7 +319,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
cmLinkItem const& dependee_name, cmLinkItem const& dependee_name,
std::set<std::string> &emitted) std::set<std::string> &emitted)
{ {
cmTarget const* depender = this->Targets[depender_index]; cmGeneratorTarget const* depender = this->Targets[depender_index];
cmTarget const* dependee = dependee_name.Target; cmTarget 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
@ -331,16 +333,17 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
if(dependee) if(dependee)
{ {
this->AddInterfaceDepends(depender_index, dependee, "", emitted); cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(dependee);
this->AddInterfaceDepends(depender_index, gt, "", emitted);
std::vector<std::string> configs; std::vector<std::string> configs;
depender->GetMakefile()->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();
it != configs.end(); ++it) it != configs.end(); ++it)
{ {
// 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, dependee, this->AddInterfaceDepends(depender_index, gt, *it, emitted);
*it, emitted);
} }
} }
} }
@ -351,7 +354,7 @@ void cmComputeTargetDepends::AddTargetDepend(
bool linking) bool linking)
{ {
// Get the depender. // Get the depender.
cmTarget 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; cmTarget const* dependee = dependee_name.Target;
@ -362,7 +365,7 @@ void cmComputeTargetDepends::AddTargetDepend(
cmake::MessageType messageType = cmake::AUTHOR_WARNING; cmake::MessageType messageType = cmake::AUTHOR_WARNING;
bool issueMessage = false; bool issueMessage = false;
std::ostringstream e; std::ostringstream e;
switch(depender->GetPolicyStatusCMP0046()) switch(depender->Target->GetPolicyStatusCMP0046())
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0046) << "\n"; e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0046) << "\n";
@ -383,7 +386,7 @@ void cmComputeTargetDepends::AddTargetDepend(
<< "\" of target \"" << depender->GetName() << "\" does not exist."; << "\" of target \"" << depender->GetName() << "\" does not exist.";
cmListFileBacktrace const* backtrace = cmListFileBacktrace const* backtrace =
depender->GetUtilityBacktrace(dependee_name); depender->Target->GetUtilityBacktrace(dependee_name);
if(backtrace) if(backtrace)
{ {
cm->IssueMessage(messageType, e.str(), *backtrace); cm->IssueMessage(messageType, e.str(), *backtrace);
@ -408,27 +411,31 @@ void cmComputeTargetDepends::AddTargetDepend(
if(dependee) if(dependee)
{ {
this->AddTargetDepend(depender_index, dependee, linking); cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(dependee);
this->AddTargetDepend(depender_index, gt, linking);
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmComputeTargetDepends::AddTargetDepend(int depender_index, void cmComputeTargetDepends::AddTargetDepend(int depender_index,
cmTarget const* dependee, const cmGeneratorTarget* dependee,
bool linking) bool linking)
{ {
if(dependee->IsImported() || if(dependee->Target->IsImported() ||
dependee->GetType() == cmTarget::INTERFACE_LIBRARY) dependee->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
// Skip IMPORTED and INTERFACE targets but follow their utility // Skip IMPORTED and INTERFACE targets but follow their utility
// dependencies. // dependencies.
std::set<cmLinkItem> const& utils = dependee->GetUtilityItems(); std::set<cmLinkItem> const& utils = dependee->Target->GetUtilityItems();
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(cmTarget const* transitive_dependee = i->Target)
{ {
this->AddTargetDepend(depender_index, transitive_dependee, false); cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(transitive_dependee);
this->AddTargetDepend(depender_index, gt, false);
} }
} }
} }
@ -436,7 +443,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
{ {
// Lookup the index for this target. All targets should be known by // Lookup the index for this target. All targets should be known by
// this point. // this point.
std::map<cmTarget const*, int>::const_iterator tii = std::map<cmGeneratorTarget const*, int>::const_iterator tii =
this->TargetIndex.find(dependee); this->TargetIndex.find(dependee);
assert(tii != this->TargetIndex.end()); assert(tii != this->TargetIndex.end());
int dependee_index = tii->second; int dependee_index = tii->second;
@ -457,13 +464,13 @@ cmComputeTargetDepends::DisplayGraph(Graph const& graph,
for(int depender_index = 0; depender_index < n; ++depender_index) for(int depender_index = 0; depender_index < n; ++depender_index)
{ {
EdgeList const& nl = graph[depender_index]; EdgeList const& nl = graph[depender_index];
cmTarget const* depender = this->Targets[depender_index]; cmGeneratorTarget const* depender = this->Targets[depender_index];
fprintf(stderr, "target %d is [%s]\n", fprintf(stderr, "target %d is [%s]\n",
depender_index, depender->GetName().c_str()); depender_index, depender->GetName().c_str());
for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
{ {
int dependee_index = *ni; int dependee_index = *ni;
cmTarget const* dependee = this->Targets[dependee_index]; cmGeneratorTarget const* dependee = this->Targets[dependee_index];
fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index, fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index,
dependee->GetName().c_str(), ni->IsStrong()? "strong" : "weak"); dependee->GetName().c_str(), ni->IsStrong()? "strong" : "weak");
} }
@ -550,11 +557,11 @@ cmComputeTargetDepends
{ {
// Get the depender. // Get the depender.
int i = *ci; int i = *ci;
cmTarget const* depender = this->Targets[i]; cmGeneratorTarget const* depender = this->Targets[i];
// Describe the depender. // Describe the depender.
e << " \"" << depender->GetName() << "\" of type " e << " \"" << depender->GetName() << "\" of type "
<< cmTarget::GetTargetTypeName(depender->GetType()) << "\n"; << cmTarget::GetTargetTypeName(depender->Target->GetType()) << "\n";
// List its dependencies that are inside the component. // List its dependencies that are inside the component.
EdgeList const& nl = this->InitialGraph[i]; EdgeList const& nl = this->InitialGraph[i];
@ -563,7 +570,7 @@ cmComputeTargetDepends
int j = *ni; int j = *ni;
if(cmap[j] == c) if(cmap[j] == c)
{ {
cmTarget const* dependee = this->Targets[j]; cmGeneratorTarget const* dependee = this->Targets[j];
e << " depends on \"" << dependee->GetName() << "\"" e << " depends on \"" << dependee->GetName() << "\""
<< " (" << (ni->IsStrong()? "strong" : "weak") << ")\n"; << " (" << (ni->IsStrong()? "strong" : "weak") << ")\n";
} }

View File

@ -21,7 +21,7 @@
class cmComputeComponentGraph; class cmComputeComponentGraph;
class cmGlobalGenerator; class cmGlobalGenerator;
class cmLinkItem; class cmLinkItem;
class cmTarget; class cmGeneratorTarget;
class cmTargetDependSet; class cmTargetDependSet;
/** \class cmComputeTargetDepends /** \class cmComputeTargetDepends
@ -39,9 +39,10 @@ public:
bool Compute(); bool Compute();
std::vector<cmTarget const*> const& std::vector<cmGeneratorTarget const*> const&
GetTargets() const { return this->Targets; } GetTargets() const { return this->Targets; }
void GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps); void GetTargetDirectDepends(cmGeneratorTarget const* t,
cmTargetDependSet& deps);
private: private:
void CollectTargets(); void CollectTargets();
void CollectDepends(); void CollectDepends();
@ -49,13 +50,14 @@ private:
void AddTargetDepend(int depender_index, void AddTargetDepend(int depender_index,
cmLinkItem const& dependee_name, cmLinkItem const& dependee_name,
bool linking); bool linking);
void AddTargetDepend(int depender_index, cmTarget const* dependee, void AddTargetDepend(int depender_index, cmGeneratorTarget const* dependee,
bool linking); bool linking);
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
void AddInterfaceDepends(int depender_index, void AddInterfaceDepends(int depender_index,
cmLinkItem const& dependee_name, cmLinkItem const& dependee_name,
std::set<std::string> &emitted); std::set<std::string> &emitted);
void AddInterfaceDepends(int depender_index, cmTarget const* dependee, void AddInterfaceDepends(int depender_index,
cmGeneratorTarget const* dependee,
const std::string& config, const std::string& config,
std::set<std::string> &emitted); std::set<std::string> &emitted);
cmGlobalGenerator* GlobalGenerator; cmGlobalGenerator* GlobalGenerator;
@ -63,8 +65,8 @@ private:
bool NoCycles; bool NoCycles;
// Collect all targets. // Collect all targets.
std::vector<cmTarget const*> Targets; std::vector<cmGeneratorTarget const*> Targets;
std::map<cmTarget const*, int> TargetIndex; std::map<cmGeneratorTarget const*, int> TargetIndex;
// Represent the target dependency graph. The entry at each // Represent the target dependency graph. The entry at each
// top-level index corresponds to a depender whose dependencies are // top-level index corresponds to a depender whose dependencies are

View File

@ -355,11 +355,11 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries()
{ {
// library directories // library directories
cmTargetDependSet tds = cmTargetDependSet tds =
this->GetGlobalGenerator()->GetTargetDirectDepends(*this->Target); this->GetGlobalGenerator()->GetTargetDirectDepends(this->GeneratorTarget);
for (cmTargetDependSet::iterator tdsI = tds.begin(); tdsI != tds.end(); for (cmTargetDependSet::iterator tdsI = tds.begin(); tdsI != tds.end();
++tdsI) ++tdsI)
{ {
const cmTarget *tg(*tdsI); const cmTarget *tg = (*tdsI)->Target;
*this->GetFolderBuildStreams() << " -L\"" << GetAbsBuildFilePath(tg) *this->GetFolderBuildStreams() << " -L\"" << GetAbsBuildFilePath(tg)
<< "\"" << std::endl; << "\"" << std::endl;
} }

View File

@ -1354,9 +1354,9 @@ bool cmGlobalGenerator::ComputeTargetDepends()
{ {
return false; return false;
} }
std::vector<cmTarget const*> const& targets = ctd.GetTargets(); std::vector<cmGeneratorTarget const*> const& targets = ctd.GetTargets();
for(std::vector<cmTarget const*>::const_iterator ti = targets.begin(); for(std::vector<cmGeneratorTarget const*>::const_iterator ti
ti != targets.end(); ++ti) = targets.begin(); ti != targets.end(); ++ti)
{ {
ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]); ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]);
} }
@ -2050,12 +2050,13 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
// Add dependencies of the included target. An excluded // Add dependencies of the included target. An excluded
// target may still be included if it is a dependency of a // target may still be included if it is a dependency of a
// non-excluded target. // non-excluded target.
TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(target); cmGeneratorTarget* gt = this->GetGeneratorTarget(&target);
TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(gt);
for(TargetDependSet::const_iterator ti = tgtdeps.begin(); for(TargetDependSet::const_iterator ti = tgtdeps.begin();
ti != tgtdeps.end(); ++ti) ti != tgtdeps.end(); ++ti)
{ {
cmTarget const* ttt = *ti; cmGeneratorTarget const* ttt = *ti;
targetSet.insert(ttt); targetSet.insert(ttt->Target);
} }
} }
} }
@ -2517,9 +2518,9 @@ void cmGlobalGenerator::AppendDirectoryForConfig(const std::string&,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGlobalGenerator::TargetDependSet const& cmGlobalGenerator::TargetDependSet const&
cmGlobalGenerator::GetTargetDirectDepends(cmTarget const& target) cmGlobalGenerator::GetTargetDirectDepends(cmGeneratorTarget const* target)
{ {
return this->TargetDependencies[&target]; return this->TargetDependencies[target];
} }
void cmGlobalGenerator::AddTarget(cmTarget* t) void cmGlobalGenerator::AddTarget(cmTarget* t)
@ -2619,9 +2620,10 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets,
continue; continue;
} }
// put the target in the set of original targets // put the target in the set of original targets
originalTargets.insert(target); cmGeneratorTarget* gt = this->GetGeneratorTarget(target);
originalTargets.insert(gt);
// Get the set of targets that depend on target // Get the set of targets that depend on target
this->AddTargetDepends(target, projectTargets); this->AddTargetDepends(gt, projectTargets);
} }
} }
} }
@ -2634,7 +2636,7 @@ bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalGenerator::AddTargetDepends(cmTarget const* target, void cmGlobalGenerator::AddTargetDepends(cmGeneratorTarget const* target,
TargetDependSet& projectTargets) TargetDependSet& projectTargets)
{ {
// add the target itself // add the target itself
@ -2642,11 +2644,10 @@ void cmGlobalGenerator::AddTargetDepends(cmTarget const* target,
{ {
// This is the first time we have encountered the target. // This is the first time we have encountered the target.
// Recursively follow its dependencies. // Recursively follow its dependencies.
TargetDependSet const& ts = this->GetTargetDirectDepends(*target); TargetDependSet const& ts = this->GetTargetDirectDepends(target);
for(TargetDependSet::const_iterator i = ts.begin(); i != ts.end(); ++i) for(TargetDependSet::const_iterator i = ts.begin(); i != ts.end(); ++i)
{ {
cmTarget const* dtarget = *i; this->AddTargetDepends(*i, projectTargets);
this->AddTargetDepends(dtarget, projectTargets);
} }
} }
} }

View File

@ -292,7 +292,8 @@ public:
// what targets does the specified target depend on directly // what targets does the specified target depend on directly
// via a target_link_libraries or add_dependencies // via a target_link_libraries or add_dependencies
TargetDependSet const& GetTargetDirectDepends(cmTarget const& target); TargetDependSet const& GetTargetDirectDepends(
const cmGeneratorTarget* target);
/** Get per-target generator information. */ /** Get per-target generator information. */
cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const; cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const;
@ -368,7 +369,7 @@ protected:
TargetDependSet& originalTargets, TargetDependSet& originalTargets,
cmLocalGenerator* root, GeneratorVector const&); cmLocalGenerator* root, GeneratorVector const&);
bool IsRootOnlyTarget(cmTarget* target) const; bool IsRootOnlyTarget(cmTarget* target) const;
void AddTargetDepends(cmTarget const* target, void AddTargetDepends(const cmGeneratorTarget* target,
TargetDependSet& projectTargets); TargetDependSet& projectTargets);
void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf); void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf);
void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf); void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf);
@ -477,7 +478,7 @@ private:
std::vector<std::string> FilesReplacedDuringGenerate; std::vector<std::string> FilesReplacedDuringGenerate;
// Store computed inter-target dependencies. // Store computed inter-target dependencies.
typedef std::map<cmTarget const*, TargetDependSet> TargetDependMap; typedef std::map<cmGeneratorTarget const*, TargetDependSet> TargetDependMap;
TargetDependMap TargetDependencies; TargetDependMap TargetDependencies;
// Per-target generator information. // Per-target generator information.

View File

@ -949,8 +949,8 @@ cmGlobalNinjaGenerator
std::set<std::string> const& utils = target->GetUtilities(); std::set<std::string> const& utils = target->GetUtilities();
std::copy(utils.begin(), utils.end(), std::back_inserter(outputs)); std::copy(utils.begin(), utils.end(), std::back_inserter(outputs));
} else { } else {
cmTargetDependSet const& targetDeps = cmGeneratorTarget* gt = this->GetGeneratorTarget(target);
this->GetTargetDirectDepends(*target); cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(gt);
for (cmTargetDependSet::const_iterator i = targetDeps.begin(); for (cmTargetDependSet::const_iterator i = targetDeps.begin();
i != targetDeps.end(); ++i) i != targetDeps.end(); ++i)
{ {
@ -958,7 +958,7 @@ cmGlobalNinjaGenerator
{ {
continue; continue;
} }
this->AppendTargetOutputs(*i, outputs); this->AppendTargetOutputs((*i)->Target, outputs);
} }
} }
} }

View File

@ -804,7 +804,7 @@ cmGlobalUnixMakefileGenerator3
lg->AppendEcho(commands, "Built target " + name, lg->AppendEcho(commands, "Built target " + name,
cmLocalUnixMakefileGenerator3::EchoNormal, &progress); cmLocalUnixMakefileGenerator3::EchoNormal, &progress);
this->AppendGlobalTargetDepends(depends,*gtarget->Target); this->AppendGlobalTargetDepends(depends, gtarget);
lg->WriteMakeRule(ruleFileStream, "All Build rule for target.", lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
localName, depends, commands, true); localName, depends, commands, true);
@ -832,7 +832,7 @@ cmGlobalUnixMakefileGenerator3
// //
std::set<cmTarget const*> emitted; std::set<cmTarget const*> emitted;
progCmd << " " progCmd << " "
<< this->CountProgressMarksInTarget(gtarget->Target, emitted); << this->CountProgressMarksInTarget(gtarget, emitted);
commands.push_back(progCmd.str()); commands.push_back(progCmd.str());
} }
std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
@ -908,14 +908,14 @@ cmGlobalUnixMakefileGenerator3
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
size_t size_t
cmGlobalUnixMakefileGenerator3 cmGlobalUnixMakefileGenerator3
::CountProgressMarksInTarget(cmTarget const* target, ::CountProgressMarksInTarget(cmGeneratorTarget const* target,
std::set<cmTarget const*>& emitted) std::set<cmTarget const*>& emitted)
{ {
size_t count = 0; size_t count = 0;
if(emitted.insert(target).second) if(emitted.insert(target->Target).second)
{ {
count = this->ProgressMap[target].Marks.size(); count = this->ProgressMap[target->Target].Marks.size();
TargetDependSet const& depends = this->GetTargetDirectDepends(*target); TargetDependSet const& depends = this->GetTargetDirectDepends(target);
for(TargetDependSet::const_iterator di = depends.begin(); for(TargetDependSet::const_iterator di = depends.begin();
di != depends.end(); ++di) di != depends.end(); ++di)
{ {
@ -941,7 +941,8 @@ cmGlobalUnixMakefileGenerator3
for(std::set<cmTarget const*>::const_iterator t = targets.begin(); for(std::set<cmTarget const*>::const_iterator t = targets.begin();
t != targets.end(); ++t) t != targets.end(); ++t)
{ {
count += this->CountProgressMarksInTarget(*t, emitted); cmGeneratorTarget* gt = this->GetGeneratorTarget(*t);
count += this->CountProgressMarksInTarget(gt, emitted);
} }
return count; return count;
} }
@ -987,22 +988,21 @@ cmGlobalUnixMakefileGenerator3::TargetProgress
void void
cmGlobalUnixMakefileGenerator3 cmGlobalUnixMakefileGenerator3
::AppendGlobalTargetDepends(std::vector<std::string>& depends, ::AppendGlobalTargetDepends(std::vector<std::string>& depends,
cmTarget& target) cmGeneratorTarget* target)
{ {
TargetDependSet const& depends_set = this->GetTargetDirectDepends(target); TargetDependSet const& depends_set = this->GetTargetDirectDepends(target);
for(TargetDependSet::const_iterator i = depends_set.begin(); for(TargetDependSet::const_iterator i = depends_set.begin();
i != depends_set.end(); ++i) i != depends_set.end(); ++i)
{ {
// Create the target-level dependency. // Create the target-level dependency.
cmTarget const* dep = *i; cmGeneratorTarget const* dep = *i;
if (dep->GetType() == cmTarget::INTERFACE_LIBRARY) if (dep->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
continue; continue;
} }
cmLocalUnixMakefileGenerator3* lg3 = cmLocalUnixMakefileGenerator3* lg3 =
static_cast<cmLocalUnixMakefileGenerator3*> static_cast<cmLocalUnixMakefileGenerator3*>(dep->GetLocalGenerator());
(dep->GetMakefile()->GetLocalGenerator()); std::string tgtName = lg3->GetRelativeTargetDirectory(*(*dep).Target);
std::string tgtName = lg3->GetRelativeTargetDirectory(*dep);
tgtName += "/all"; tgtName += "/all";
depends.push_back(tgtName); depends.push_back(tgtName);
} }

View File

@ -153,7 +153,7 @@ protected:
cmLocalUnixMakefileGenerator3* lg); cmLocalUnixMakefileGenerator3* lg);
void AppendGlobalTargetDepends(std::vector<std::string>& depends, void AppendGlobalTargetDepends(std::vector<std::string>& depends,
cmTarget& target); cmGeneratorTarget* target);
// does this generator need a requires step for any of its targets // does this generator need a requires step for any of its targets
bool NeedRequiresStep(cmTarget const&); bool NeedRequiresStep(cmTarget const&);
@ -198,7 +198,7 @@ protected:
cmStrictTargetComparison> ProgressMapType; cmStrictTargetComparison> ProgressMapType;
ProgressMapType ProgressMap; ProgressMapType ProgressMap;
size_t CountProgressMarksInTarget(cmTarget const* target, size_t CountProgressMarksInTarget(cmGeneratorTarget const* target,
std::set<cmTarget const*>& emitted); std::set<cmTarget const*>& emitted);
size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg); size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg);

View File

@ -224,7 +224,7 @@ void cmGlobalVisualStudio6Generator
tt = orderedProjectTargets.begin(); tt = orderedProjectTargets.begin();
tt != orderedProjectTargets.end(); ++tt) tt != orderedProjectTargets.end(); ++tt)
{ {
cmTarget const* target = *tt; cmTarget const* target = (*tt)->Target;
if(target->GetType() == cmTarget::INTERFACE_LIBRARY) if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
continue; continue;

View File

@ -402,7 +402,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
for(OrderedTargetDependSet::const_iterator tt = for(OrderedTargetDependSet::const_iterator tt =
projectTargets.begin(); tt != projectTargets.end(); ++tt) projectTargets.begin(); tt != projectTargets.end(); ++tt)
{ {
cmTarget const* target = *tt; cmTarget const* target = (*tt)->Target;
if(target->GetType() == cmTarget::INTERFACE_LIBRARY) if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
continue; continue;
@ -442,7 +442,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
for(OrderedTargetDependSet::const_iterator tt = for(OrderedTargetDependSet::const_iterator tt =
projectTargets.begin(); tt != projectTargets.end(); ++tt) projectTargets.begin(); tt != projectTargets.end(); ++tt)
{ {
cmTarget const* target = *tt; cmTarget const* target = (*tt)->Target;
if(target->GetType() == cmTarget::INTERFACE_LIBRARY) if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
continue; continue;
@ -534,7 +534,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends(
for(OrderedTargetDependSet::const_iterator tt = for(OrderedTargetDependSet::const_iterator tt =
projectTargets.begin(); tt != projectTargets.end(); ++tt) projectTargets.begin(); tt != projectTargets.end(); ++tt)
{ {
cmTarget const* target = *tt; cmTarget const* target = (*tt)->Target;
if(target->GetType() == cmTarget::INTERFACE_LIBRARY) if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
continue; continue;
@ -1045,12 +1045,12 @@ cmGlobalVisualStudio7Generator
::IsDependedOn(OrderedTargetDependSet const& projectTargets, ::IsDependedOn(OrderedTargetDependSet const& projectTargets,
cmTarget const* targetIn) cmTarget const* targetIn)
{ {
cmGeneratorTarget* gtIn = this->GetGeneratorTarget(targetIn);
for (OrderedTargetDependSet::const_iterator l = projectTargets.begin(); for (OrderedTargetDependSet::const_iterator l = projectTargets.begin();
l != projectTargets.end(); ++l) l != projectTargets.end(); ++l)
{ {
cmTarget const& target = **l; TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(*l);
TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(target); if(tgtdeps.count(gtIn))
if(tgtdeps.count(targetIn))
{ {
return true; return true;
} }

View File

@ -441,7 +441,8 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends()
void cmGlobalVisualStudio8Generator::WriteProjectDepends( void cmGlobalVisualStudio8Generator::WriteProjectDepends(
std::ostream& fout, const std::string&, const char*, cmTarget const& t) std::ostream& fout, const std::string&, const char*, cmTarget const& t)
{ {
TargetDependSet const& unordered = this->GetTargetDirectDepends(t); cmGeneratorTarget* gt = this->GetGeneratorTarget(&t);
TargetDependSet const& unordered = this->GetTargetDirectDepends(gt);
OrderedTargetDependSet depends(unordered); OrderedTargetDependSet depends(unordered);
for(OrderedTargetDependSet::const_iterator i = depends.begin(); for(OrderedTargetDependSet::const_iterator i = depends.begin();
i != depends.end(); ++i) i != depends.end(); ++i)

View File

@ -299,13 +299,14 @@ void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget const* target,
{ {
if(linked.insert(target).second) if(linked.insert(target).second)
{ {
TargetDependSet const& depends = this->GetTargetDirectDepends(*target); cmGeneratorTarget* gt = this->GetGeneratorTarget(target);
TargetDependSet const& depends = this->GetTargetDirectDepends(gt);
for(TargetDependSet::const_iterator di = depends.begin(); for(TargetDependSet::const_iterator di = depends.begin();
di != depends.end(); ++di) di != depends.end(); ++di)
{ {
if(di->IsLink()) if(di->IsLink())
{ {
this->FillLinkClosure(*di, linked); this->FillLinkClosure((*di)->Target, linked);
} }
} }
} }
@ -338,13 +339,14 @@ void cmGlobalVisualStudioGenerator::FollowLinkDepends(
{ {
// Static library targets do not list their link dependencies so // Static library targets do not list their link dependencies so
// we must follow them transitively now. // we must follow them transitively now.
TargetDependSet const& depends = this->GetTargetDirectDepends(*target); cmGeneratorTarget* gt = this->GetGeneratorTarget(target);
TargetDependSet const& depends = this->GetTargetDirectDepends(gt);
for(TargetDependSet::const_iterator di = depends.begin(); for(TargetDependSet::const_iterator di = depends.begin();
di != depends.end(); ++di) di != depends.end(); ++di)
{ {
if(di->IsLink()) if(di->IsLink())
{ {
this->FollowLinkDepends(*di, linked); this->FollowLinkDepends((*di)->Target, linked);
} }
} }
} }
@ -413,7 +415,8 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
target.GetType() != cmTarget::MODULE_LIBRARY && target.GetType() != cmTarget::MODULE_LIBRARY &&
target.GetType() != cmTarget::EXECUTABLE); target.GetType() != cmTarget::EXECUTABLE);
TargetDependSet const& depends = this->GetTargetDirectDepends(target); cmGeneratorTarget* gt = this->GetGeneratorTarget(&target);
TargetDependSet const& depends = this->GetTargetDirectDepends(gt);
// Collect implicit link dependencies (target_link_libraries). // Collect implicit link dependencies (target_link_libraries).
// Static libraries cannot depend on their link implementation // Static libraries cannot depend on their link implementation
@ -427,7 +430,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
cmTargetDepend dep = *di; cmTargetDepend dep = *di;
if(dep.IsLink()) if(dep.IsLink())
{ {
this->FollowLinkDepends(dep, linkDepends); this->FollowLinkDepends(dep->Target, linkDepends);
} }
} }
} }
@ -440,7 +443,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
cmTargetDepend dep = *di; cmTargetDepend dep = *di;
if(dep.IsUtil()) if(dep.IsUtil())
{ {
this->FollowLinkDepends(dep, utilDepends); this->FollowLinkDepends(dep->Target, utilDepends);
} }
} }
@ -843,7 +846,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
cmGlobalVisualStudioGenerator::TargetCompare cmGlobalVisualStudioGenerator::TargetCompare
::operator()(cmTarget const* l, cmTarget const* r) const ::operator()(cmGeneratorTarget const* l, cmGeneratorTarget const* r) const
{ {
// Make sure ALL_BUILD is first so it is the default active project. // Make sure ALL_BUILD is first so it is the default active project.
if(r->GetName() == "ALL_BUILD") if(r->GetName() == "ALL_BUILD")
@ -868,7 +871,13 @@ cmGlobalVisualStudioGenerator::OrderedTargetDependSet
cmGlobalVisualStudioGenerator::OrderedTargetDependSet cmGlobalVisualStudioGenerator::OrderedTargetDependSet
::OrderedTargetDependSet(TargetSet const& targets) ::OrderedTargetDependSet(TargetSet const& targets)
{ {
this->insert(targets.begin(), targets.end()); for (TargetSet::const_iterator it = targets.begin();
it != targets.end(); ++it)
{
cmGeneratorTarget* gt =
(*it)->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(*it);
this->insert(gt);
}
} }
std::string cmGlobalVisualStudioGenerator::ExpandCFGIntDir( std::string cmGlobalVisualStudioGenerator::ExpandCFGIntDir(

View File

@ -91,7 +91,8 @@ public:
class TargetSet: public std::set<cmTarget const*> {}; class TargetSet: public std::set<cmTarget const*> {};
struct TargetCompare struct TargetCompare
{ {
bool operator()(cmTarget const* l, cmTarget const* r) const; bool operator()(cmGeneratorTarget const* l,
cmGeneratorTarget const* r) const;
}; };
class OrderedTargetDependSet; class OrderedTargetDependSet;

View File

@ -2895,10 +2895,11 @@ void cmGlobalXCodeGenerator
} }
// Add dependencies on other CMake targets. // Add dependencies on other CMake targets.
TargetDependSet const& deps = this->GetTargetDirectDepends(*cmtarget); cmGeneratorTarget* gt = this->GetGeneratorTarget(cmtarget);
TargetDependSet const& deps = this->GetTargetDirectDepends(gt);
for(TargetDependSet::const_iterator i = deps.begin(); i != deps.end(); ++i) for(TargetDependSet::const_iterator i = deps.begin(); i != deps.end(); ++i)
{ {
if(cmXCodeObject* dptarget = this->FindXCodeTarget(*i)) if(cmXCodeObject* dptarget = this->FindXCodeTarget((*i)->Target))
{ {
this->AddDependTarget(target, dptarget); this->AddDependTarget(target, dptarget);
} }

View File

@ -14,23 +14,24 @@
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
class cmTarget; class cmGeneratorTarget;
/** One edge in the global target dependency graph. /** One edge in the global target dependency graph.
It may be marked as a 'link' or 'util' edge or both. */ It may be marked as a 'link' or 'util' edge or both. */
class cmTargetDepend class cmTargetDepend
{ {
cmTarget const* Target; cmGeneratorTarget const* Target;
// The set order depends only on the Target, so we use // The set order depends only on the Target, so we use
// mutable members to acheive a map with set syntax. // mutable members to acheive a map with set syntax.
mutable bool Link; mutable bool Link;
mutable bool Util; mutable bool Util;
public: public:
cmTargetDepend(cmTarget const* t): Target(t), Link(false), Util(false) {} cmTargetDepend(cmGeneratorTarget const* t)
operator cmTarget const*() const { return this->Target; } : Target(t), Link(false), Util(false) {}
cmTarget const* operator->() const { return this->Target; } operator cmGeneratorTarget const*() const { return this->Target; }
cmTarget const& operator*() const { return *this->Target; } cmGeneratorTarget const* operator->() const { return this->Target; }
cmGeneratorTarget const& operator*() const { return *this->Target; }
friend bool operator < (cmTargetDepend const& l, cmTargetDepend const& r) friend bool operator < (cmTargetDepend const& l, cmTargetDepend const& r)
{ return l.Target < r.Target; } { return l.Target < r.Target; }
void SetType(bool strong) const void SetType(bool strong) const

View File

@ -2660,7 +2660,7 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
void cmVisualStudio10TargetGenerator::WriteProjectReferences() void cmVisualStudio10TargetGenerator::WriteProjectReferences()
{ {
cmGlobalGenerator::TargetDependSet const& unordered cmGlobalGenerator::TargetDependSet const& unordered
= this->GlobalGenerator->GetTargetDirectDepends(*this->Target); = this->GlobalGenerator->GetTargetDirectDepends(this->GeneratorTarget);
typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet
OrderedTargetDependSet; OrderedTargetDependSet;
OrderedTargetDependSet depends(unordered); OrderedTargetDependSet depends(unordered);
@ -2668,7 +2668,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
for( OrderedTargetDependSet::const_iterator i = depends.begin(); for( OrderedTargetDependSet::const_iterator i = depends.begin();
i != depends.end(); ++i) i != depends.end(); ++i)
{ {
cmTarget const* dt = *i; cmTarget const* dt = (*i)->Target;
if(dt->GetType() == cmTarget::INTERFACE_LIBRARY) if(dt->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
continue; continue;