Constify handling of target dependencies.

This commit is contained in:
Stephen Kelly 2013-12-10 15:16:23 +01:00
parent 97fae68b81
commit ef25ba8d06
24 changed files with 122 additions and 105 deletions

View File

@ -143,12 +143,13 @@ bool cmComputeTargetDepends::Compute()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t, cmComputeTargetDepends::GetTargetDirectDepends(cmTarget 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*, int>::const_iterator tii = this->TargetIndex.find(t); std::map<cmTarget const*, int>::const_iterator tii
= this->TargetIndex.find(t);
assert(tii != this->TargetIndex.end()); assert(tii != this->TargetIndex.end());
int i = tii->second; int i = tii->second;
@ -156,7 +157,7 @@ cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* 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* dep = this->Targets[*ni]; cmTarget 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());
} }
@ -170,10 +171,11 @@ void cmComputeTargetDepends::CollectTargets()
this->GlobalGenerator->GetLocalGenerators(); this->GlobalGenerator->GetLocalGenerators();
for(unsigned int i = 0; i < lgens.size(); ++i) for(unsigned int i = 0; i < lgens.size(); ++i)
{ {
cmTargets& targets = lgens[i]->GetMakefile()->GetTargets(); const cmTargets& targets = lgens[i]->GetMakefile()->GetTargets();
for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) for(cmTargets::const_iterator ti = targets.begin();
ti != targets.end(); ++ti)
{ {
cmTarget* target = &ti->second; cmTarget const* target = &ti->second;
int index = static_cast<int>(this->Targets.size()); int index = static_cast<int>(this->Targets.size());
this->TargetIndex[target] = index; this->TargetIndex[target] = index;
this->Targets.push_back(target); this->Targets.push_back(target);
@ -198,7 +200,7 @@ void cmComputeTargetDepends::CollectDepends()
void cmComputeTargetDepends::CollectTargetDepends(int depender_index) void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
{ {
// Get the depender. // Get the depender.
cmTarget* depender = this->Targets[depender_index]; cmTarget const* depender = this->Targets[depender_index];
if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) if (depender->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
return; return;
@ -271,11 +273,11 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
cmTarget* dependee, cmTarget const* dependee,
const char *config, const char *config,
std::set<cmStdString> &emitted) std::set<cmStdString> &emitted)
{ {
cmTarget* depender = this->Targets[depender_index]; cmTarget const* depender = this->Targets[depender_index];
if(cmTarget::LinkInterface const* iface = if(cmTarget::LinkInterface const* iface =
dependee->GetLinkInterface(config, depender)) dependee->GetLinkInterface(config, depender))
{ {
@ -300,8 +302,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
bool linking, bool linking,
std::set<cmStdString> &emitted) std::set<cmStdString> &emitted)
{ {
cmTarget* depender = this->Targets[depender_index]; cmTarget const* depender = this->Targets[depender_index];
cmTarget* dependee = cmTarget const* dependee =
depender->GetMakefile()->FindTargetToUse(dependee_name); depender->GetMakefile()->FindTargetToUse(dependee_name);
// 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
@ -335,10 +337,10 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
bool linking) bool linking)
{ {
// Get the depender. // Get the depender.
cmTarget* depender = this->Targets[depender_index]; cmTarget const* depender = this->Targets[depender_index];
// Check the target's makefile first. // Check the target's makefile first.
cmTarget* dependee = cmTarget const* dependee =
depender->GetMakefile()->FindTargetToUse(dependee_name); depender->GetMakefile()->FindTargetToUse(dependee_name);
// Skip targets that will not really be linked. This is probably a // Skip targets that will not really be linked. This is probably a
@ -359,7 +361,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmComputeTargetDepends::AddTargetDepend(int depender_index, void cmComputeTargetDepends::AddTargetDepend(int depender_index,
cmTarget* dependee, cmTarget const* dependee,
bool linking) bool linking)
{ {
if(dependee->IsImported()) if(dependee->IsImported())
@ -369,7 +371,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
for(std::set<cmStdString>::const_iterator i = utils.begin(); for(std::set<cmStdString>::const_iterator i = utils.begin();
i != utils.end(); ++i) i != utils.end(); ++i)
{ {
if(cmTarget* transitive_dependee = if(cmTarget const* transitive_dependee =
dependee->GetMakefile()->FindTargetToUse(i->c_str())) dependee->GetMakefile()->FindTargetToUse(i->c_str()))
{ {
this->AddTargetDepend(depender_index, transitive_dependee, false); this->AddTargetDepend(depender_index, transitive_dependee, false);
@ -380,7 +382,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*, int>::const_iterator tii = std::map<cmTarget 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;
@ -400,13 +402,13 @@ cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name)
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* depender = this->Targets[depender_index]; cmTarget const* depender = this->Targets[depender_index];
fprintf(stderr, "target %d is [%s]\n", fprintf(stderr, "target %d is [%s]\n",
depender_index, depender->GetName()); depender_index, depender->GetName());
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* dependee = this->Targets[dependee_index]; cmTarget 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(), ni->IsStrong()? "strong" : "weak"); dependee->GetName(), ni->IsStrong()? "strong" : "weak");
} }
@ -493,7 +495,7 @@ cmComputeTargetDepends
{ {
// Get the depender. // Get the depender.
int i = *ci; int i = *ci;
cmTarget* depender = this->Targets[i]; cmTarget const* depender = this->Targets[i];
// Describe the depender. // Describe the depender.
e << " \"" << depender->GetName() << "\" of type " e << " \"" << depender->GetName() << "\" of type "
@ -506,7 +508,7 @@ cmComputeTargetDepends
int j = *ni; int j = *ni;
if(cmap[j] == c) if(cmap[j] == c)
{ {
cmTarget* dependee = this->Targets[j]; cmTarget 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

@ -38,19 +38,21 @@ public:
bool Compute(); bool Compute();
std::vector<cmTarget*> const& GetTargets() const { return this->Targets; } std::vector<cmTarget const*> const&
void GetTargetDirectDepends(cmTarget* t, cmTargetDependSet& deps); GetTargets() const { return this->Targets; }
void GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps);
private: private:
void CollectTargets(); void CollectTargets();
void CollectDepends(); void CollectDepends();
void CollectTargetDepends(int depender_index); void CollectTargetDepends(int depender_index);
void AddTargetDepend(int depender_index, const char* dependee_name, void AddTargetDepend(int depender_index, const char* dependee_name,
bool linking); bool linking);
void AddTargetDepend(int depender_index, cmTarget* dependee, bool linking); void AddTargetDepend(int depender_index, cmTarget const* dependee,
bool linking);
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
void AddInterfaceDepends(int depender_index, const char* dependee_name, void AddInterfaceDepends(int depender_index, const char* dependee_name,
bool linking, std::set<cmStdString> &emitted); bool linking, std::set<cmStdString> &emitted);
void AddInterfaceDepends(int depender_index, cmTarget* dependee, void AddInterfaceDepends(int depender_index, cmTarget const* dependee,
const char *config, const char *config,
std::set<cmStdString> &emitted); std::set<cmStdString> &emitted);
cmGlobalGenerator* GlobalGenerator; cmGlobalGenerator* GlobalGenerator;
@ -58,8 +60,8 @@ private:
bool NoCycles; bool NoCycles;
// Collect all targets. // Collect all targets.
std::vector<cmTarget*> Targets; std::vector<cmTarget const*> Targets;
std::map<cmTarget*, int> TargetIndex; std::map<cmTarget 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

@ -950,7 +950,7 @@ void cmGlobalGenerator::ClearEnabledLanguages()
} }
bool cmGlobalGenerator::IsDependedOn(const char* project, bool cmGlobalGenerator::IsDependedOn(const char* project,
cmTarget* targetIn) cmTarget const* targetIn)
{ {
// Get all local gens for this project // Get all local gens for this project
std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project]; std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project];
@ -1214,8 +1214,8 @@ bool cmGlobalGenerator::ComputeTargetDepends()
{ {
return false; return false;
} }
std::vector<cmTarget*> const& targets = ctd.GetTargets(); std::vector<cmTarget const*> const& targets = ctd.GetTargets();
for(std::vector<cmTarget*>::const_iterator ti = targets.begin(); for(std::vector<cmTarget const*>::const_iterator ti = targets.begin();
ti != targets.end(); ++ti) ti != targets.end(); ++ti)
{ {
ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]); ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]);
@ -1954,7 +1954,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
clg = clg->GetParent()) clg = clg->GetParent())
{ {
// This local generator includes the target. // This local generator includes the target.
std::set<cmTarget*>& targetSet = std::set<cmTarget const*>& targetSet =
this->LocalGeneratorToTargetMap[clg]; this->LocalGeneratorToTargetMap[clg];
targetSet.insert(&target); targetSet.insert(&target);
@ -1965,7 +1965,8 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
for(TargetDependSet::const_iterator ti = tgtdeps.begin(); for(TargetDependSet::const_iterator ti = tgtdeps.begin();
ti != tgtdeps.end(); ++ti) ti != tgtdeps.end(); ++ti)
{ {
targetSet.insert(*ti); cmTarget const* ttt = *ti;
targetSet.insert(ttt);
} }
} }
} }
@ -2478,7 +2479,7 @@ void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGlobalGenerator::TargetDependSet const& cmGlobalGenerator::TargetDependSet const&
cmGlobalGenerator::GetTargetDirectDepends(cmTarget & target) cmGlobalGenerator::GetTargetDirectDepends(cmTarget const& target)
{ {
return this->TargetDependencies[&target]; return this->TargetDependencies[&target];
} }
@ -2600,7 +2601,7 @@ bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalGenerator::AddTargetDepends(cmTarget* target, void cmGlobalGenerator::AddTargetDepends(cmTarget const* target,
TargetDependSet& projectTargets) TargetDependSet& projectTargets)
{ {
// add the target itself // add the target itself
@ -2611,7 +2612,7 @@ void cmGlobalGenerator::AddTargetDepends(cmTarget* target,
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* dtarget = *i; cmTarget const* dtarget = *i;
this->AddTargetDepends(dtarget, projectTargets); this->AddTargetDepends(dtarget, projectTargets);
} }
} }

View File

@ -218,7 +218,7 @@ public:
/** If check to see if the target is linked to by any other /** If check to see if the target is linked to by any other
target in the project */ target in the project */
bool IsDependedOn(const char* project, cmTarget* target); bool IsDependedOn(const char* project, cmTarget const* target);
///! Find a local generator by its startdirectory ///! Find a local generator by its startdirectory
cmLocalGenerator* FindLocalGenerator(const char* start_dir); cmLocalGenerator* FindLocalGenerator(const char* start_dir);
@ -266,7 +266,7 @@ 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 & target); TargetDependSet const& GetTargetDirectDepends(cmTarget const& target);
/** Get per-target generator information. */ /** Get per-target generator information. */
cmGeneratorTarget* GetGeneratorTarget(cmTarget*) const; cmGeneratorTarget* GetGeneratorTarget(cmTarget*) const;
@ -323,7 +323,8 @@ protected:
TargetDependSet& originalTargets, TargetDependSet& originalTargets,
cmLocalGenerator* root, GeneratorVector const&); cmLocalGenerator* root, GeneratorVector const&);
virtual bool IsRootOnlyTarget(cmTarget* target); virtual bool IsRootOnlyTarget(cmTarget* target);
void AddTargetDepends(cmTarget* target, TargetDependSet& projectTargets); void AddTargetDepends(cmTarget const* target,
TargetDependSet& projectTargets);
void SetLanguageEnabledFlag(const char* l, cmMakefile* mf); void SetLanguageEnabledFlag(const char* l, cmMakefile* mf);
void SetLanguageEnabledMaps(const char* l, cmMakefile* mf); void SetLanguageEnabledMaps(const char* l, cmMakefile* mf);
void FillExtensionToLanguageMap(const char* l, cmMakefile* mf); void FillExtensionToLanguageMap(const char* l, cmMakefile* mf);
@ -362,7 +363,8 @@ protected:
cmLocalGenerator* CurrentLocalGenerator; cmLocalGenerator* CurrentLocalGenerator;
// map from project name to vector of local generators in that project // map from project name to vector of local generators in that project
std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap; std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap;
std::map<cmLocalGenerator*, std::set<cmTarget *> > LocalGeneratorToTargetMap; std::map<cmLocalGenerator*, std::set<cmTarget const*> >
LocalGeneratorToTargetMap;
// Set of named installation components requested by the project. // Set of named installation components requested by the project.
std::set<cmStdString> InstallComponents; std::set<cmStdString> InstallComponents;
@ -420,7 +422,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 *, TargetDependSet> TargetDependMap; typedef std::map<cmTarget const*, TargetDependSet> TargetDependMap;
TargetDependMap TargetDependencies; TargetDependMap TargetDependencies;
// Per-target generator information. // Per-target generator information.

View File

@ -830,7 +830,7 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies()
void void
cmGlobalNinjaGenerator cmGlobalNinjaGenerator
::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) ::AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs)
{ {
const char* configName = const char* configName =
target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE"); target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE");
@ -879,7 +879,7 @@ cmGlobalNinjaGenerator
void void
cmGlobalNinjaGenerator cmGlobalNinjaGenerator
::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs) ::AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs)
{ {
if (target->GetType() == cmTarget::GLOBAL_TARGET) { if (target->GetType() == cmTarget::GLOBAL_TARGET) {
// Global targets only depend on other utilities, which may not appear in // Global targets only depend on other utilities, which may not appear in

View File

@ -283,8 +283,8 @@ public:
ASD.insert(deps.begin(), deps.end()); ASD.insert(deps.begin(), deps.end());
} }
void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs); void AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs);
void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); void AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs);
void AddDependencyToAll(cmTarget* target); void AddDependencyToAll(cmTarget* target);
void AddDependencyToAll(const std::string& input); void AddDependencyToAll(const std::string& input);

View File

@ -841,7 +841,7 @@ cmGlobalUnixMakefileGenerator3
cmLocalGenerator::FULL, cmLocalGenerator::FULL,
cmLocalGenerator::SHELL); cmLocalGenerator::SHELL);
// //
std::set<cmTarget *> emitted; std::set<cmTarget const*> emitted;
progCmd << " " progCmd << " "
<< this->CountProgressMarksInTarget(t->second->Target, emitted); << this->CountProgressMarksInTarget(t->second->Target, emitted);
commands.push_back(progCmd.str()); commands.push_back(progCmd.str());
@ -919,8 +919,8 @@ cmGlobalUnixMakefileGenerator3
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
size_t size_t
cmGlobalUnixMakefileGenerator3 cmGlobalUnixMakefileGenerator3
::CountProgressMarksInTarget(cmTarget* target, ::CountProgressMarksInTarget(cmTarget const* target,
std::set<cmTarget*>& emitted) std::set<cmTarget const*>& emitted)
{ {
size_t count = 0; size_t count = 0;
if(emitted.insert(target).second) if(emitted.insert(target).second)
@ -946,9 +946,10 @@ cmGlobalUnixMakefileGenerator3
::CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg) ::CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg)
{ {
size_t count = 0; size_t count = 0;
std::set<cmTarget*> emitted; std::set<cmTarget const*> emitted;
std::set<cmTarget*> const& targets = this->LocalGeneratorToTargetMap[lg]; std::set<cmTarget const*> const& targets
for(std::set<cmTarget*>::const_iterator t = targets.begin(); = this->LocalGeneratorToTargetMap[lg];
for(std::set<cmTarget const*>::const_iterator t = targets.begin();
t != targets.end(); ++t) t != targets.end(); ++t)
{ {
count += this->CountProgressMarksInTarget(*t, emitted); count += this->CountProgressMarksInTarget(*t, emitted);
@ -969,7 +970,7 @@ cmGlobalUnixMakefileGenerator3::RecordTargetProgress(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool bool
cmGlobalUnixMakefileGenerator3::ProgressMapCompare cmGlobalUnixMakefileGenerator3::ProgressMapCompare
::operator()(cmTarget* l, cmTarget* r) const ::operator()(cmTarget const* l, cmTarget const* r) const
{ {
// Order by target name. // Order by target name.
if(int c = strcmp(l->GetName(), r->GetName())) if(int c = strcmp(l->GetName(), r->GetName()))

View File

@ -181,13 +181,14 @@ protected:
std::vector<unsigned long> Marks; std::vector<unsigned long> Marks;
void WriteProgressVariables(unsigned long total, unsigned long& current); void WriteProgressVariables(unsigned long total, unsigned long& current);
}; };
struct ProgressMapCompare { bool operator()(cmTarget*,cmTarget*) const; }; struct ProgressMapCompare { bool operator()(cmTarget const*,
typedef std::map<cmTarget*, TargetProgress, cmTarget const*) const; };
typedef std::map<cmTarget const*, TargetProgress,
ProgressMapCompare> ProgressMapType; ProgressMapCompare> ProgressMapType;
ProgressMapType ProgressMap; ProgressMapType ProgressMap;
size_t CountProgressMarksInTarget(cmTarget* target, size_t CountProgressMarksInTarget(cmTarget const* target,
std::set<cmTarget*>& emitted); std::set<cmTarget const*>& emitted);
size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg); size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg);
cmGeneratedFileStream *CommandDatabase; cmGeneratedFileStream *CommandDatabase;

View File

@ -205,7 +205,7 @@ void cmGlobalVisualStudio6Generator
tt = orderedProjectTargets.begin(); tt = orderedProjectTargets.begin();
tt != orderedProjectTargets.end(); ++tt) tt != orderedProjectTargets.end(); ++tt)
{ {
cmTarget* target = *tt; cmTarget const* target = *tt;
if(target->GetType() == cmTarget::INTERFACE_LIBRARY) if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
continue; continue;
@ -271,7 +271,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile()
void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
const char* dspname, const char* dspname,
const char* dir, const char* dir,
cmTarget& target) cmTarget const& target)
{ {
fout << "#########################################################" fout << "#########################################################"
"######################\n\n"; "######################\n\n";
@ -364,7 +364,7 @@ void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string std::string
cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget* target) cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget const* target)
{ {
std::string pname = target->GetName(); std::string pname = target->GetName();
pname += "_UTILITY"; pname += "_UTILITY";

View File

@ -99,12 +99,12 @@ private:
void WriteDSWFile(std::ostream& fout); void WriteDSWFile(std::ostream& fout);
void WriteDSWHeader(std::ostream& fout); void WriteDSWHeader(std::ostream& fout);
void WriteProject(std::ostream& fout, void WriteProject(std::ostream& fout,
const char* name, const char* path, cmTarget &t); const char* name, const char* path, cmTarget const& t);
void WriteExternalProject(std::ostream& fout, void WriteExternalProject(std::ostream& fout,
const char* name, const char* path, const char* name, const char* path,
const std::set<cmStdString>& dependencies); const std::set<cmStdString>& dependencies);
void WriteDSWFooter(std::ostream& fout); void WriteDSWFooter(std::ostream& fout);
virtual std::string WriteUtilityDepend(cmTarget* target); virtual std::string WriteUtilityDepend(cmTarget const* target);
std::string MSDevCommand; std::string MSDevCommand;
bool MSDevCommandInitialized; bool MSDevCommandInitialized;
std::string const& GetMSDevCommand(); std::string const& GetMSDevCommand();

View File

@ -157,7 +157,7 @@ void
cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
const char* dspname, const char* dspname,
const char* dir, const char* dir,
cmTarget& t) cmTarget const& t)
{ {
// check to see if this is a fortran build // check to see if this is a fortran build
const char* ext = ".vcproj"; const char* ext = ".vcproj";
@ -209,7 +209,7 @@ void
cmGlobalVisualStudio71Generator cmGlobalVisualStudio71Generator
::WriteProjectDepends(std::ostream& fout, ::WriteProjectDepends(std::ostream& fout,
const char*, const char*,
const char*, cmTarget& target) const char*, cmTarget const& target)
{ {
VSDependSet const& depends = this->VSTargetDepends[&target]; VSDependSet const& depends = this->VSTargetDepends[&target];
for(VSDependSet::const_iterator di = depends.begin(); for(VSDependSet::const_iterator di = depends.begin();

View File

@ -59,9 +59,11 @@ protected:
std::vector<cmLocalGenerator*>& generators); std::vector<cmLocalGenerator*>& generators);
virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteSolutionConfigurations(std::ostream& fout);
virtual void WriteProject(std::ostream& fout, virtual void WriteProject(std::ostream& fout,
const char* name, const char* path, cmTarget &t); const char* name, const char* path,
cmTarget const& t);
virtual void WriteProjectDepends(std::ostream& fout, virtual void WriteProjectDepends(std::ostream& fout,
const char* name, const char* path, cmTarget &t); const char* name, const char* path,
cmTarget const& t);
virtual void WriteProjectConfigurations( virtual void WriteProjectConfigurations(
std::ostream& fout, const char* name, cmTarget::TargetType type, std::ostream& fout, const char* name, cmTarget::TargetType type,
const std::set<std::string>& configsPartOfDefaultBuild, const std::set<std::string>& configsPartOfDefaultBuild,

View File

@ -335,7 +335,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* target = *tt; cmTarget const* target = *tt;
if(target->GetType() == cmTarget::INTERFACE_LIBRARY) if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
continue; continue;
@ -376,7 +376,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* target = *tt; cmTarget const* target = *tt;
if(target->GetType() == cmTarget::INTERFACE_LIBRARY) if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
continue; continue;
@ -470,7 +470,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* target = *tt; cmTarget const* target = *tt;
if(target->GetType() == cmTarget::INTERFACE_LIBRARY) if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
continue; continue;
@ -619,7 +619,7 @@ cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path)
// the libraries it uses are also done here // the libraries it uses are also done here
void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout, void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout,
const char* dspname, const char* dspname,
const char* dir, cmTarget& target) const char* dir, cmTarget const& target)
{ {
// check to see if this is a fortran build // check to see if this is a fortran build
const char* ext = ".vcproj"; const char* ext = ".vcproj";
@ -659,7 +659,7 @@ void
cmGlobalVisualStudio7Generator cmGlobalVisualStudio7Generator
::WriteProjectDepends(std::ostream& fout, ::WriteProjectDepends(std::ostream& fout,
const char* dspname, const char* dspname,
const char*, cmTarget& target) const char*, cmTarget const& target)
{ {
int depcount = 0; int depcount = 0;
std::string dspguid = this->GetGUID(dspname); std::string dspguid = this->GetGUID(dspname);
@ -819,7 +819,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string std::string
cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget* target) cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
{ {
std::string pname = target->GetName(); std::string pname = target->GetName();
pname += "_UTILITY"; pname += "_UTILITY";
@ -940,7 +940,7 @@ cmGlobalVisualStudio7Generator
std::set<std::string> std::set<std::string>
cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project, cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project,
cmTarget* target) cmTarget const* target)
{ {
std::set<std::string> activeConfigs; std::set<std::string> activeConfigs;
// if it is a utilitiy target then only make it part of the // if it is a utilitiy target then only make it part of the

View File

@ -121,9 +121,11 @@ protected:
virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators); std::vector<cmLocalGenerator*>& generators);
virtual void WriteProject(std::ostream& fout, virtual void WriteProject(std::ostream& fout,
const char* name, const char* path, cmTarget &t); const char* name, const char* path,
cmTarget const& t);
virtual void WriteProjectDepends(std::ostream& fout, virtual void WriteProjectDepends(std::ostream& fout,
const char* name, const char* path, cmTarget &t); const char* name, const char* path,
cmTarget const&t);
virtual void WriteProjectConfigurations( virtual void WriteProjectConfigurations(
std::ostream& fout, const char* name, cmTarget::TargetType type, std::ostream& fout, const char* name, cmTarget::TargetType type,
const std::set<std::string>& configsPartOfDefaultBuild, const std::set<std::string>& configsPartOfDefaultBuild,
@ -132,7 +134,7 @@ protected:
cmLocalGenerator* root); cmLocalGenerator* root);
virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout);
virtual std::string WriteUtilityDepend(cmTarget* target); virtual std::string WriteUtilityDepend(cmTarget const* target);
virtual void WriteTargetsToSolution( virtual void WriteTargetsToSolution(
std::ostream& fout, std::ostream& fout,
@ -158,7 +160,7 @@ protected:
std::string ConvertToSolutionPath(const char* path); std::string ConvertToSolutionPath(const char* path);
std::set<std::string> IsPartOfDefaultBuild(const char* project, std::set<std::string> IsPartOfDefaultBuild(const char* project,
cmTarget* target); cmTarget const* target);
std::vector<std::string> Configurations; std::vector<std::string> Configurations;
std::map<cmStdString, cmStdString> GUIDMap; std::map<cmStdString, cmStdString> GUIDMap;

View File

@ -415,7 +415,7 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio8Generator::WriteProjectDepends( void cmGlobalVisualStudio8Generator::WriteProjectDepends(
std::ostream& fout, const char*, const char*, cmTarget& t) std::ostream& fout, const char*, const char*, cmTarget const& t)
{ {
TargetDependSet const& unordered = this->GetTargetDirectDepends(t); TargetDependSet const& unordered = this->GetTargetDirectDepends(t);
OrderedTargetDependSet depends(unordered); OrderedTargetDependSet depends(unordered);

View File

@ -84,7 +84,7 @@ protected:
const char* platformMapping = NULL); const char* platformMapping = NULL);
virtual bool ComputeTargetDepends(); virtual bool ComputeTargetDepends();
virtual void WriteProjectDepends(std::ostream& fout, const char* name, virtual void WriteProjectDepends(std::ostream& fout, const char* name,
const char* path, cmTarget &t); const char* path, cmTarget const& t);
std::string Name; std::string Name;
std::string WindowsCEVersion; std::string WindowsCEVersion;

View File

@ -315,7 +315,7 @@ std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget* target, void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget const* target,
TargetSet& linked) TargetSet& linked)
{ {
if(linked.insert(target).second) if(linked.insert(target).second)
@ -348,7 +348,7 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmTarget* target)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudioGenerator::FollowLinkDepends( void cmGlobalVisualStudioGenerator::FollowLinkDepends(
cmTarget* target, std::set<cmTarget*>& linked) cmTarget const* target, std::set<cmTarget const*>& linked)
{ {
if(target->GetType() == cmTarget::INTERFACE_LIBRARY) if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
@ -397,7 +397,7 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static bool VSLinkable(cmTarget* t) static bool VSLinkable(cmTarget const* t)
{ {
return t->IsLinkable() || t->GetType() == cmTarget::OBJECT_LIBRARY; return t->IsLinkable() || t->GetType() == cmTarget::OBJECT_LIBRARY;
} }
@ -439,7 +439,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
// 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
// due to behavior (2), but they do not really need to. // due to behavior (2), but they do not really need to.
std::set<cmTarget*> linkDepends; std::set<cmTarget const*> linkDepends;
if(target.GetType() != cmTarget::STATIC_LIBRARY) if(target.GetType() != cmTarget::STATIC_LIBRARY)
{ {
for(TargetDependSet::const_iterator di = depends.begin(); for(TargetDependSet::const_iterator di = depends.begin();
@ -454,7 +454,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
} }
// Collect explicit util dependencies (add_dependencies). // Collect explicit util dependencies (add_dependencies).
std::set<cmTarget*> utilDepends; std::set<cmTarget const*> utilDepends;
for(TargetDependSet::const_iterator di = depends.begin(); for(TargetDependSet::const_iterator di = depends.begin();
di != depends.end(); ++di) di != depends.end(); ++di)
{ {
@ -474,18 +474,18 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
} }
// Emit link dependencies. // Emit link dependencies.
for(std::set<cmTarget*>::iterator di = linkDepends.begin(); for(std::set<cmTarget const*>::iterator di = linkDepends.begin();
di != linkDepends.end(); ++di) di != linkDepends.end(); ++di)
{ {
cmTarget* dep = *di; cmTarget const* dep = *di;
vsTargetDepend.insert(dep->GetName()); vsTargetDepend.insert(dep->GetName());
} }
// Emit util dependencies. Possibly use intermediate targets. // Emit util dependencies. Possibly use intermediate targets.
for(std::set<cmTarget*>::iterator di = utilDepends.begin(); for(std::set<cmTarget const*>::iterator di = utilDepends.begin();
di != utilDepends.end(); ++di) di != utilDepends.end(); ++di)
{ {
cmTarget* dep = *di; cmTarget const* dep = *di;
if(allowLinkable || !VSLinkable(dep) || linked.count(dep)) if(allowLinkable || !VSLinkable(dep) || linked.count(dep))
{ {
// Direct dependency allowed. // Direct dependency allowed.
@ -523,7 +523,8 @@ void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget* target) std::string
cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget const* target)
{ {
UtilityDependsMap::iterator i = this->UtilityDepends.find(target); UtilityDependsMap::iterator i = this->UtilityDepends.find(target);
if(i == this->UtilityDepends.end()) if(i == this->UtilityDepends.end())
@ -845,7 +846,8 @@ void RegisterVisualStudioMacros(const std::string& macrosFile,
} }
} }
} }
bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget& target) bool
cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
{ {
// check to see if this is a fortran build // check to see if this is a fortran build
std::set<cmStdString> languages; std::set<cmStdString> languages;

View File

@ -60,7 +60,7 @@ public:
const char* vsSolutionFile = 0); const char* vsSolutionFile = 0);
// return true if target is fortran only // return true if target is fortran only
bool TargetIsFortranOnly(cmTarget& t); bool TargetIsFortranOnly(cmTarget const& t);
/** Get the top-level registry key for this VS version. */ /** Get the top-level registry key for this VS version. */
std::string GetRegistryBase(); std::string GetRegistryBase();
@ -75,7 +75,7 @@ public:
/** Return true if building for Windows CE */ /** Return true if building for Windows CE */
virtual bool TargetsWindowsCE() const { return false; } virtual bool TargetsWindowsCE() const { return false; }
class TargetSet: public std::set<cmTarget*> {}; class TargetSet: public std::set<cmTarget const*> {};
struct TargetCompare struct TargetCompare
{ {
bool operator()(cmTarget const* l, cmTarget const* r) const; bool operator()(cmTarget const* l, cmTarget const* r) const;
@ -96,15 +96,15 @@ protected:
virtual bool ComputeTargetDepends(); virtual bool ComputeTargetDepends();
class VSDependSet: public std::set<cmStdString> {}; class VSDependSet: public std::set<cmStdString> {};
class VSDependMap: public std::map<cmTarget*, VSDependSet> {}; class VSDependMap: public std::map<cmTarget const*, VSDependSet> {};
VSDependMap VSTargetDepends; VSDependMap VSTargetDepends;
void ComputeVSTargetDepends(cmTarget&); void ComputeVSTargetDepends(cmTarget&);
bool CheckTargetLinks(cmTarget& target, const char* name); bool CheckTargetLinks(cmTarget& target, const char* name);
std::string GetUtilityForTarget(cmTarget& target, const char*); std::string GetUtilityForTarget(cmTarget& target, const char*);
virtual std::string WriteUtilityDepend(cmTarget*) = 0; virtual std::string WriteUtilityDepend(cmTarget const*) = 0;
std::string GetUtilityDepend(cmTarget* target); std::string GetUtilityDepend(cmTarget const* target);
typedef std::map<cmTarget*, cmStdString> UtilityDependsMap; typedef std::map<cmTarget const*, cmStdString> UtilityDependsMap;
UtilityDependsMap UtilityDepends; UtilityDependsMap UtilityDepends;
const char* AdditionalPlatformDefinition; const char* AdditionalPlatformDefinition;
@ -113,11 +113,12 @@ private:
void PrintCompilerAdvice(std::ostream&, std::string, const char*) {} void PrintCompilerAdvice(std::ostream&, std::string, const char*) {}
void ComputeTargetObjects(cmGeneratorTarget* gt) const; void ComputeTargetObjects(cmGeneratorTarget* gt) const;
void FollowLinkDepends(cmTarget* target, std::set<cmTarget*>& linked); void FollowLinkDepends(cmTarget const* target,
std::set<cmTarget const*>& linked);
class TargetSetMap: public std::map<cmTarget*, TargetSet> {}; class TargetSetMap: public std::map<cmTarget*, TargetSet> {};
TargetSetMap TargetLinkClosure; TargetSetMap TargetLinkClosure;
void FillLinkClosure(cmTarget* target, TargetSet& linked); void FillLinkClosure(cmTarget const* target, TargetSet& linked);
TargetSet const& GetTargetLinkClosure(cmTarget* target); TargetSet const& GetTargetLinkClosure(cmTarget* target);
}; };

View File

@ -2622,7 +2622,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget* t) cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t)
{ {
if(!t) if(!t)
{ {

View File

@ -125,7 +125,7 @@ private:
multipleOutputPairs multipleOutputPairs
); );
cmXCodeObject* FindXCodeTarget(cmTarget*); cmXCodeObject* FindXCodeTarget(cmTarget const*);
std::string GetOrCreateId(const char* name, const char* id); std::string GetOrCreateId(const char* name, const char* id);
// create cmXCodeObject from these functions so that memory can be managed // create cmXCodeObject from these functions so that memory can be managed

View File

@ -828,7 +828,8 @@ void cmTarget::GetDirectLinkLibraries(const char *config,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::GetInterfaceLinkLibraries(const char *config, void cmTarget::GetInterfaceLinkLibraries(const char *config,
std::vector<std::string> &libs, cmTarget *head) const std::vector<std::string> &libs,
cmTarget const* head) const
{ {
const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES"); const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES");
if (prop) if (prop)

View File

@ -187,7 +187,7 @@ public:
cmTarget const* head) const; cmTarget const* head) const;
void GetInterfaceLinkLibraries(const char *config, void GetInterfaceLinkLibraries(const char *config,
std::vector<std::string> &, std::vector<std::string> &,
cmTarget *head) const; cmTarget const* head) const;
/** Compute the link type to use for the given configuration. */ /** Compute the link type to use for the given configuration. */
LinkLibraryType ComputeLinkType(const char* config) const; LinkLibraryType ComputeLinkType(const char* config) const;

View File

@ -20,17 +20,17 @@ class cmTarget;
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* Target; cmTarget 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* t): Target(t), Link(false), Util(false) {} cmTargetDepend(cmTarget const* t): Target(t), Link(false), Util(false) {}
operator cmTarget*() const { return this->Target; } operator cmTarget const*() const { return this->Target; }
cmTarget* operator->() const { return this->Target; } cmTarget const* operator->() const { return this->Target; }
cmTarget& operator*() const { return *this->Target; } cmTarget 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

@ -1841,7 +1841,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* dt = *i; cmTarget const* dt = *i;
if(dt->GetType() == cmTarget::INTERFACE_LIBRARY) if(dt->GetType() == cmTarget::INTERFACE_LIBRARY)
{ {
continue; continue;