From ef25ba8d066ed06d59f975ecfac55569ee369402 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 10 Dec 2013 15:16:23 +0100 Subject: Constify handling of target dependencies. --- Source/cmComputeTargetDepends.cxx | 42 ++++++++++++++++-------------- Source/cmComputeTargetDepends.h | 14 +++++----- Source/cmGlobalGenerator.cxx | 17 ++++++------ Source/cmGlobalGenerator.h | 12 +++++---- Source/cmGlobalNinjaGenerator.cxx | 4 +-- Source/cmGlobalNinjaGenerator.h | 4 +-- Source/cmGlobalUnixMakefileGenerator3.cxx | 15 ++++++----- Source/cmGlobalUnixMakefileGenerator3.h | 9 ++++--- Source/cmGlobalVisualStudio6Generator.cxx | 6 ++--- Source/cmGlobalVisualStudio6Generator.h | 4 +-- Source/cmGlobalVisualStudio71Generator.cxx | 4 +-- Source/cmGlobalVisualStudio71Generator.h | 6 +++-- Source/cmGlobalVisualStudio7Generator.cxx | 14 +++++----- Source/cmGlobalVisualStudio7Generator.h | 10 ++++--- Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmGlobalVisualStudio8Generator.h | 2 +- Source/cmGlobalVisualStudioGenerator.cxx | 24 +++++++++-------- Source/cmGlobalVisualStudioGenerator.h | 17 ++++++------ Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmGlobalXCodeGenerator.h | 2 +- Source/cmTarget.cxx | 3 ++- Source/cmTarget.h | 2 +- Source/cmTargetDepend.h | 10 +++---- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- 24 files changed, 122 insertions(+), 105 deletions(-) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 02fd173..73a8e27 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -143,12 +143,13 @@ bool cmComputeTargetDepends::Compute() //---------------------------------------------------------------------------- void -cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t, +cmComputeTargetDepends::GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps) { // Lookup the index for this target. All targets should be known by // this point. - std::map::const_iterator tii = this->TargetIndex.find(t); + std::map::const_iterator tii + = this->TargetIndex.find(t); assert(tii != this->TargetIndex.end()); int i = tii->second; @@ -156,7 +157,7 @@ cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t, EdgeList const& nl = this->FinalGraph[i]; 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; di->SetType(ni->IsStrong()); } @@ -170,10 +171,11 @@ void cmComputeTargetDepends::CollectTargets() this->GlobalGenerator->GetLocalGenerators(); for(unsigned int i = 0; i < lgens.size(); ++i) { - cmTargets& targets = lgens[i]->GetMakefile()->GetTargets(); - for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) + const cmTargets& targets = lgens[i]->GetMakefile()->GetTargets(); + for(cmTargets::const_iterator ti = targets.begin(); + ti != targets.end(); ++ti) { - cmTarget* target = &ti->second; + cmTarget const* target = &ti->second; int index = static_cast(this->Targets.size()); this->TargetIndex[target] = index; this->Targets.push_back(target); @@ -198,7 +200,7 @@ void cmComputeTargetDepends::CollectDepends() void cmComputeTargetDepends::CollectTargetDepends(int depender_index) { // Get the depender. - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) { return; @@ -271,11 +273,11 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, - cmTarget* dependee, + cmTarget const* dependee, const char *config, std::set &emitted) { - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; if(cmTarget::LinkInterface const* iface = dependee->GetLinkInterface(config, depender)) { @@ -300,8 +302,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, bool linking, std::set &emitted) { - cmTarget* depender = this->Targets[depender_index]; - cmTarget* dependee = + cmTarget const* depender = this->Targets[depender_index]; + cmTarget const* dependee = depender->GetMakefile()->FindTargetToUse(dependee_name); // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable @@ -335,10 +337,10 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, bool linking) { // Get the depender. - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; // Check the target's makefile first. - cmTarget* dependee = + cmTarget const* dependee = depender->GetMakefile()->FindTargetToUse(dependee_name); // 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, - cmTarget* dependee, + cmTarget const* dependee, bool linking) { if(dependee->IsImported()) @@ -369,7 +371,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, for(std::set::const_iterator i = utils.begin(); i != utils.end(); ++i) { - if(cmTarget* transitive_dependee = + if(cmTarget const* transitive_dependee = dependee->GetMakefile()->FindTargetToUse(i->c_str())) { 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 // this point. - std::map::const_iterator tii = + std::map::const_iterator tii = this->TargetIndex.find(dependee); assert(tii != this->TargetIndex.end()); 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) { 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", depender_index, depender->GetName()); for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++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, dependee->GetName(), ni->IsStrong()? "strong" : "weak"); } @@ -493,7 +495,7 @@ cmComputeTargetDepends { // Get the depender. int i = *ci; - cmTarget* depender = this->Targets[i]; + cmTarget const* depender = this->Targets[i]; // Describe the depender. e << " \"" << depender->GetName() << "\" of type " @@ -506,7 +508,7 @@ cmComputeTargetDepends int j = *ni; if(cmap[j] == c) { - cmTarget* dependee = this->Targets[j]; + cmTarget const* dependee = this->Targets[j]; e << " depends on \"" << dependee->GetName() << "\"" << " (" << (ni->IsStrong()? "strong" : "weak") << ")\n"; } diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index d6131cf..6cd6da0 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -38,19 +38,21 @@ public: bool Compute(); - std::vector const& GetTargets() const { return this->Targets; } - void GetTargetDirectDepends(cmTarget* t, cmTargetDependSet& deps); + std::vector const& + GetTargets() const { return this->Targets; } + void GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps); private: void CollectTargets(); void CollectDepends(); void CollectTargetDepends(int depender_index); void AddTargetDepend(int depender_index, const char* dependee_name, 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); void AddInterfaceDepends(int depender_index, const char* dependee_name, bool linking, std::set &emitted); - void AddInterfaceDepends(int depender_index, cmTarget* dependee, + void AddInterfaceDepends(int depender_index, cmTarget const* dependee, const char *config, std::set &emitted); cmGlobalGenerator* GlobalGenerator; @@ -58,8 +60,8 @@ private: bool NoCycles; // Collect all targets. - std::vector Targets; - std::map TargetIndex; + std::vector Targets; + std::map TargetIndex; // Represent the target dependency graph. The entry at each // top-level index corresponds to a depender whose dependencies are diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index e6f3d94..91a7594 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -950,7 +950,7 @@ void cmGlobalGenerator::ClearEnabledLanguages() } bool cmGlobalGenerator::IsDependedOn(const char* project, - cmTarget* targetIn) + cmTarget const* targetIn) { // Get all local gens for this project std::vector* gens = &this->ProjectMap[project]; @@ -1214,8 +1214,8 @@ bool cmGlobalGenerator::ComputeTargetDepends() { return false; } - std::vector const& targets = ctd.GetTargets(); - for(std::vector::const_iterator ti = targets.begin(); + std::vector const& targets = ctd.GetTargets(); + for(std::vector::const_iterator ti = targets.begin(); ti != targets.end(); ++ti) { ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]); @@ -1954,7 +1954,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() clg = clg->GetParent()) { // This local generator includes the target. - std::set& targetSet = + std::set& targetSet = this->LocalGeneratorToTargetMap[clg]; targetSet.insert(&target); @@ -1965,7 +1965,8 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() for(TargetDependSet::const_iterator ti = tgtdeps.begin(); 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::GetTargetDirectDepends(cmTarget & target) +cmGlobalGenerator::GetTargetDirectDepends(cmTarget const& 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) { // add the target itself @@ -2611,7 +2612,7 @@ void cmGlobalGenerator::AddTargetDepends(cmTarget* target, TargetDependSet const& ts = this->GetTargetDirectDepends(*target); for(TargetDependSet::const_iterator i = ts.begin(); i != ts.end(); ++i) { - cmTarget* dtarget = *i; + cmTarget const* dtarget = *i; this->AddTargetDepends(dtarget, projectTargets); } } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index eb720a8..e90af6c 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -218,7 +218,7 @@ public: /** If check to see if the target is linked to by any other 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 cmLocalGenerator* FindLocalGenerator(const char* start_dir); @@ -266,7 +266,7 @@ public: // what targets does the specified target depend on directly // via a target_link_libraries or add_dependencies - TargetDependSet const& GetTargetDirectDepends(cmTarget & target); + TargetDependSet const& GetTargetDirectDepends(cmTarget const& target); /** Get per-target generator information. */ cmGeneratorTarget* GetGeneratorTarget(cmTarget*) const; @@ -323,7 +323,8 @@ protected: TargetDependSet& originalTargets, cmLocalGenerator* root, GeneratorVector const&); 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 SetLanguageEnabledMaps(const char* l, cmMakefile* mf); void FillExtensionToLanguageMap(const char* l, cmMakefile* mf); @@ -362,7 +363,8 @@ protected: cmLocalGenerator* CurrentLocalGenerator; // map from project name to vector of local generators in that project std::map > ProjectMap; - std::map > LocalGeneratorToTargetMap; + std::map > + LocalGeneratorToTargetMap; // Set of named installation components requested by the project. std::set InstallComponents; @@ -420,7 +422,7 @@ private: std::vector FilesReplacedDuringGenerate; // Store computed inter-target dependencies. - typedef std::map TargetDependMap; + typedef std::map TargetDependMap; TargetDependMap TargetDependencies; // Per-target generator information. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 77571b2..4b92058 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -830,7 +830,7 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies() void cmGlobalNinjaGenerator -::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) +::AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs) { const char* configName = target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE"); @@ -879,7 +879,7 @@ cmGlobalNinjaGenerator void cmGlobalNinjaGenerator -::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs) +::AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs) { if (target->GetType() == cmTarget::GLOBAL_TARGET) { // Global targets only depend on other utilities, which may not appear in diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 4fd0d5c..de38923 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -283,8 +283,8 @@ public: ASD.insert(deps.begin(), deps.end()); } - void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs); - void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); + void AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs); + void AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs); void AddDependencyToAll(cmTarget* target); void AddDependencyToAll(const std::string& input); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 52465dc..622a7c5 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -841,7 +841,7 @@ cmGlobalUnixMakefileGenerator3 cmLocalGenerator::FULL, cmLocalGenerator::SHELL); // - std::set emitted; + std::set emitted; progCmd << " " << this->CountProgressMarksInTarget(t->second->Target, emitted); commands.push_back(progCmd.str()); @@ -919,8 +919,8 @@ cmGlobalUnixMakefileGenerator3 //---------------------------------------------------------------------------- size_t cmGlobalUnixMakefileGenerator3 -::CountProgressMarksInTarget(cmTarget* target, - std::set& emitted) +::CountProgressMarksInTarget(cmTarget const* target, + std::set& emitted) { size_t count = 0; if(emitted.insert(target).second) @@ -946,9 +946,10 @@ cmGlobalUnixMakefileGenerator3 ::CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg) { size_t count = 0; - std::set emitted; - std::set const& targets = this->LocalGeneratorToTargetMap[lg]; - for(std::set::const_iterator t = targets.begin(); + std::set emitted; + std::set const& targets + = this->LocalGeneratorToTargetMap[lg]; + for(std::set::const_iterator t = targets.begin(); t != targets.end(); ++t) { count += this->CountProgressMarksInTarget(*t, emitted); @@ -969,7 +970,7 @@ cmGlobalUnixMakefileGenerator3::RecordTargetProgress( //---------------------------------------------------------------------------- bool cmGlobalUnixMakefileGenerator3::ProgressMapCompare -::operator()(cmTarget* l, cmTarget* r) const +::operator()(cmTarget const* l, cmTarget const* r) const { // Order by target name. if(int c = strcmp(l->GetName(), r->GetName())) diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 284f5d1..986d1d7 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -181,13 +181,14 @@ protected: std::vector Marks; void WriteProgressVariables(unsigned long total, unsigned long& current); }; - struct ProgressMapCompare { bool operator()(cmTarget*,cmTarget*) const; }; - typedef std::map ProgressMapType; ProgressMapType ProgressMap; - size_t CountProgressMarksInTarget(cmTarget* target, - std::set& emitted); + size_t CountProgressMarksInTarget(cmTarget const* target, + std::set& emitted); size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg); cmGeneratedFileStream *CommandDatabase; diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 614a79a..38c47ef 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -205,7 +205,7 @@ void cmGlobalVisualStudio6Generator tt = orderedProjectTargets.begin(); tt != orderedProjectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -271,7 +271,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile() void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, const char* dspname, const char* dir, - cmTarget& target) + cmTarget const& target) { fout << "#########################################################" "######################\n\n"; @@ -364,7 +364,7 @@ void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout) //---------------------------------------------------------------------------- std::string -cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget* target) +cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget const* target) { std::string pname = target->GetName(); pname += "_UTILITY"; diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index cb6cb8b..5521410 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -99,12 +99,12 @@ private: void WriteDSWFile(std::ostream& fout); void WriteDSWHeader(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, const char* name, const char* path, const std::set& dependencies); void WriteDSWFooter(std::ostream& fout); - virtual std::string WriteUtilityDepend(cmTarget* target); + virtual std::string WriteUtilityDepend(cmTarget const* target); std::string MSDevCommand; bool MSDevCommandInitialized; std::string const& GetMSDevCommand(); diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 61d3c4c..6cfad25 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -157,7 +157,7 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, const char* dspname, const char* dir, - cmTarget& t) + cmTarget const& t) { // check to see if this is a fortran build const char* ext = ".vcproj"; @@ -209,7 +209,7 @@ void cmGlobalVisualStudio71Generator ::WriteProjectDepends(std::ostream& fout, const char*, - const char*, cmTarget& target) + const char*, cmTarget const& target) { VSDependSet const& depends = this->VSTargetDepends[&target]; for(VSDependSet::const_iterator di = depends.begin(); diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index e136db7..04e3a55 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -59,9 +59,11 @@ protected: std::vector& generators); virtual void WriteSolutionConfigurations(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, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const& t); virtual void WriteProjectConfigurations( std::ostream& fout, const char* name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index a217d8c..1899b40 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -335,7 +335,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -376,7 +376,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -470,7 +470,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -619,7 +619,7 @@ cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path) // the libraries it uses are also done here void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout, const char* dspname, - const char* dir, cmTarget& target) + const char* dir, cmTarget const& target) { // check to see if this is a fortran build const char* ext = ".vcproj"; @@ -659,7 +659,7 @@ void cmGlobalVisualStudio7Generator ::WriteProjectDepends(std::ostream& fout, const char* dspname, - const char*, cmTarget& target) + const char*, cmTarget const& target) { int depcount = 0; std::string dspguid = this->GetGUID(dspname); @@ -819,7 +819,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout) //---------------------------------------------------------------------------- std::string -cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget* target) +cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target) { std::string pname = target->GetName(); pname += "_UTILITY"; @@ -940,7 +940,7 @@ cmGlobalVisualStudio7Generator std::set cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project, - cmTarget* target) + cmTarget const* target) { std::set activeConfigs; // if it is a utilitiy target then only make it part of the diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 59e74ba..611422a 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -121,9 +121,11 @@ protected: virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector& generators); 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, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const&t); virtual void WriteProjectConfigurations( std::ostream& fout, const char* name, cmTarget::TargetType type, const std::set& configsPartOfDefaultBuild, @@ -132,7 +134,7 @@ protected: cmLocalGenerator* root); virtual void WriteSLNFooter(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( std::ostream& fout, @@ -158,7 +160,7 @@ protected: std::string ConvertToSolutionPath(const char* path); std::set IsPartOfDefaultBuild(const char* project, - cmTarget* target); + cmTarget const* target); std::vector Configurations; std::map GUIDMap; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index e4ce13f..12c240b 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -415,7 +415,7 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends() //---------------------------------------------------------------------------- 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); OrderedTargetDependSet depends(unordered); diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index ad01a24..5b952c4 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -84,7 +84,7 @@ protected: const char* platformMapping = NULL); virtual bool ComputeTargetDepends(); 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 WindowsCEVersion; diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 6c782e4..93a597c 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -315,7 +315,7 @@ std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget* target, +void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget const* target, TargetSet& linked) { if(linked.insert(target).second) @@ -348,7 +348,7 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmTarget* target) //---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::FollowLinkDepends( - cmTarget* target, std::set& linked) + cmTarget const* target, std::set& linked) { 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; } @@ -439,7 +439,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) // Collect implicit link dependencies (target_link_libraries). // Static libraries cannot depend on their link implementation // due to behavior (2), but they do not really need to. - std::set linkDepends; + std::set linkDepends; if(target.GetType() != cmTarget::STATIC_LIBRARY) { for(TargetDependSet::const_iterator di = depends.begin(); @@ -454,7 +454,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) } // Collect explicit util dependencies (add_dependencies). - std::set utilDepends; + std::set utilDepends; for(TargetDependSet::const_iterator di = depends.begin(); di != depends.end(); ++di) { @@ -474,18 +474,18 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) } // Emit link dependencies. - for(std::set::iterator di = linkDepends.begin(); + for(std::set::iterator di = linkDepends.begin(); di != linkDepends.end(); ++di) { - cmTarget* dep = *di; + cmTarget const* dep = *di; vsTargetDepend.insert(dep->GetName()); } // Emit util dependencies. Possibly use intermediate targets. - for(std::set::iterator di = utilDepends.begin(); + for(std::set::iterator di = utilDepends.begin(); di != utilDepends.end(); ++di) { - cmTarget* dep = *di; + cmTarget const* dep = *di; if(allowLinkable || !VSLinkable(dep) || linked.count(dep)) { // 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); 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 std::set languages; diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index da2d021..54e3c28 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -60,7 +60,7 @@ public: const char* vsSolutionFile = 0); // 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. */ std::string GetRegistryBase(); @@ -75,7 +75,7 @@ public: /** Return true if building for Windows CE */ virtual bool TargetsWindowsCE() const { return false; } - class TargetSet: public std::set {}; + class TargetSet: public std::set {}; struct TargetCompare { bool operator()(cmTarget const* l, cmTarget const* r) const; @@ -96,15 +96,15 @@ protected: virtual bool ComputeTargetDepends(); class VSDependSet: public std::set {}; - class VSDependMap: public std::map {}; + class VSDependMap: public std::map {}; VSDependMap VSTargetDepends; void ComputeVSTargetDepends(cmTarget&); bool CheckTargetLinks(cmTarget& target, const char* name); std::string GetUtilityForTarget(cmTarget& target, const char*); - virtual std::string WriteUtilityDepend(cmTarget*) = 0; - std::string GetUtilityDepend(cmTarget* target); - typedef std::map UtilityDependsMap; + virtual std::string WriteUtilityDepend(cmTarget const*) = 0; + std::string GetUtilityDepend(cmTarget const* target); + typedef std::map UtilityDependsMap; UtilityDependsMap UtilityDepends; const char* AdditionalPlatformDefinition; @@ -113,11 +113,12 @@ private: void PrintCompilerAdvice(std::ostream&, std::string, const char*) {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; - void FollowLinkDepends(cmTarget* target, std::set& linked); + void FollowLinkDepends(cmTarget const* target, + std::set& linked); class TargetSetMap: public std::map {}; TargetSetMap TargetLinkClosure; - void FillLinkClosure(cmTarget* target, TargetSet& linked); + void FillLinkClosure(cmTarget const* target, TargetSet& linked); TargetSet const& GetTargetLinkClosure(cmTarget* target); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 215d483..b5a46d0 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2622,7 +2622,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } //---------------------------------------------------------------------------- -cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget* t) +cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t) { if(!t) { diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index e8cbd14..6281c3b 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -125,7 +125,7 @@ private: multipleOutputPairs ); - cmXCodeObject* FindXCodeTarget(cmTarget*); + cmXCodeObject* FindXCodeTarget(cmTarget const*); std::string GetOrCreateId(const char* name, const char* id); // create cmXCodeObject from these functions so that memory can be managed diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 38fe945..05b57a2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -828,7 +828,8 @@ void cmTarget::GetDirectLinkLibraries(const char *config, //---------------------------------------------------------------------------- void cmTarget::GetInterfaceLinkLibraries(const char *config, - std::vector &libs, cmTarget *head) const + std::vector &libs, + cmTarget const* head) const { const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES"); if (prop) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 3f5a5d1..bf4a8ef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -187,7 +187,7 @@ public: cmTarget const* head) const; void GetInterfaceLinkLibraries(const char *config, std::vector &, - cmTarget *head) const; + cmTarget const* head) const; /** Compute the link type to use for the given configuration. */ LinkLibraryType ComputeLinkType(const char* config) const; diff --git a/Source/cmTargetDepend.h b/Source/cmTargetDepend.h index 258bacd..1feb072 100644 --- a/Source/cmTargetDepend.h +++ b/Source/cmTargetDepend.h @@ -20,17 +20,17 @@ class cmTarget; It may be marked as a 'link' or 'util' edge or both. */ class cmTargetDepend { - cmTarget* Target; + cmTarget const* Target; // The set order depends only on the Target, so we use // mutable members to acheive a map with set syntax. mutable bool Link; mutable bool Util; public: - cmTargetDepend(cmTarget* t): Target(t), Link(false), Util(false) {} - operator cmTarget*() const { return this->Target; } - cmTarget* operator->() const { return this->Target; } - cmTarget& operator*() const { return *this->Target; } + cmTargetDepend(cmTarget const* t): Target(t), Link(false), Util(false) {} + operator cmTarget const*() const { return this->Target; } + cmTarget const* operator->() const { return this->Target; } + cmTarget const& operator*() const { return *this->Target; } friend bool operator < (cmTargetDepend const& l, cmTargetDepend const& r) { return l.Target < r.Target; } void SetType(bool strong) const diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 10663b7..b9ae701 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1841,7 +1841,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() for( OrderedTargetDependSet::const_iterator i = depends.begin(); i != depends.end(); ++i) { - cmTarget* dt = *i; + cmTarget const* dt = *i; if(dt->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; -- cgit v0.12 From 9edee62f280de840096651a817b765a38ec6d090 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 10 Dec 2013 15:30:41 +0100 Subject: Constify handling of link targets. --- Source/cmComputeLinkDepends.cxx | 11 ++++++----- Source/cmComputeLinkDepends.h | 8 ++++---- Source/cmComputeLinkInformation.cxx | 17 +++++++++-------- Source/cmComputeLinkInformation.h | 17 +++++++++-------- Source/cmExportFileGenerator.cxx | 2 +- Source/cmInstallTargetGenerator.cxx | 14 ++++++++------ Source/cmInstallTargetGenerator.h | 3 ++- Source/cmTarget.cxx | 3 ++- 8 files changed, 41 insertions(+), 34 deletions(-) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 31cc393..1be5980 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -619,19 +619,19 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index, } //---------------------------------------------------------------------------- -cmTarget* cmComputeLinkDepends::FindTargetToLink(int depender_index, +cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const char* name) { // Look for a target in the scope of the depender. cmMakefile* mf = this->Makefile; if(depender_index >= 0) { - if(cmTarget* depender = this->EntryList[depender_index].Target) + if(cmTarget const* depender = this->EntryList[depender_index].Target) { mf = depender->GetMakefile(); } } - cmTarget* tgt = mf->FindTargetToUse(name); + cmTarget const* tgt = mf->FindTargetToUse(name); // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable @@ -950,7 +950,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) int count = 2; for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - if(cmTarget* target = this->EntryList[*ni].Target) + if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = target->GetLinkInterface(this->Config, this->HeadTarget)) @@ -997,7 +997,8 @@ void cmComputeLinkDepends::CheckWrongConfigItem(int depender_index, // For CMake 2.4 bug-compatibility we need to consider the output // directories of targets linked in another configuration as link // directories. - if(cmTarget* tgt = this->FindTargetToLink(depender_index, item.c_str())) + if(cmTarget const* tgt + = this->FindTargetToLink(depender_index, item.c_str())) { if(!tgt->IsImported()) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index b86c9b2..cf227fb 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -40,7 +40,7 @@ public: struct LinkEntry { std::string Item; - cmTarget* Target; + cmTarget const* Target; bool IsSharedDep; bool IsFlag; LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {} @@ -53,7 +53,7 @@ public: EntryVector const& Compute(); void SetOldLinkDirMode(bool b); - std::set const& GetOldWrongConfigItems() const + std::set const& GetOldWrongConfigItems() const { return this->OldWrongConfigItems; } private: @@ -83,7 +83,7 @@ private: void AddDirectLinkEntries(); void AddLinkEntries(int depender_index, std::vector const& libs); - cmTarget* FindTargetToLink(int depender_index, const char* name); + cmTarget const* FindTargetToLink(int depender_index, const char* name); // One entry for each unique item. std::vector EntryList; @@ -164,7 +164,7 @@ private: // Compatibility help. bool OldLinkDirMode; void CheckWrongConfigItem(int depender_index, std::string const& item); - std::set OldWrongConfigItems; + std::set OldWrongConfigItems; }; #endif diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 0ef3d2e..f3bdddd 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -477,7 +477,7 @@ std::vector const& cmComputeLinkInformation::GetFrameworkPaths() } //---------------------------------------------------------------------------- -std::set const& +std::set const& cmComputeLinkInformation::GetSharedLibrariesLinked() { return this->SharedLibrariesLinked; @@ -542,11 +542,11 @@ bool cmComputeLinkInformation::Compute() // For CMake 2.4 bug-compatibility we need to consider the output // directories of targets linked in another configuration as link // directories. - std::set const& wrongItems = cld.GetOldWrongConfigItems(); - for(std::set::const_iterator i = wrongItems.begin(); + std::set const& wrongItems = cld.GetOldWrongConfigItems(); + for(std::set::const_iterator i = wrongItems.begin(); i != wrongItems.end(); ++i) { - cmTarget* tgt = *i; + cmTarget const* tgt = *i; bool implib = (this->UseImportLibrary && (tgt->GetType() == cmTarget::SHARED_LIBRARY)); @@ -620,7 +620,8 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) } //---------------------------------------------------------------------------- -void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) +void cmComputeLinkInformation::AddItem(std::string const& item, + cmTarget const* tgt) { // Compute the proper name to use to link this library. const char* config = this->Config; @@ -700,7 +701,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, - cmTarget* tgt) + cmTarget const* tgt) { // If dropping shared library dependencies, ignore them. if(this->SharedDependencyMode == SharedDepModeNone) @@ -1062,7 +1063,7 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt) //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddTargetItem(std::string const& item, - cmTarget* target) + cmTarget const* target) { // This is called to handle a link item that is a full path to a target. // If the target is not a static library make sure the link type is @@ -1744,7 +1745,7 @@ cmComputeLinkInformation::GetRuntimeSearchPath() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, - cmTarget* target) + cmTarget const* target) { // Ignore targets on Apple where install_name is not @rpath. // The dependenty library can be found with other means such as diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 1da5495..356e6ed 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -39,11 +39,11 @@ public: Item(): Value(), IsPath(true), Target(0) {} Item(Item const& item): Value(item.Value), IsPath(item.IsPath), Target(item.Target) {} - Item(std::string const& v, bool p, cmTarget* target = 0): + Item(std::string const& v, bool p, cmTarget const* target = 0): Value(v), IsPath(p), Target(target) {} std::string Value; bool IsPath; - cmTarget* Target; + cmTarget const* Target; }; typedef std::vector ItemVector; ItemVector const& GetItems(); @@ -57,13 +57,13 @@ public: void GetRPath(std::vector& runtimeDirs, bool for_install); std::string GetRPathString(bool for_install); std::string GetChrpathString(); - std::set const& GetSharedLibrariesLinked(); + std::set const& GetSharedLibrariesLinked(); std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; } std::string GetRPathLinkString(); private: - void AddItem(std::string const& item, cmTarget* tgt); - void AddSharedDepItem(std::string const& item, cmTarget* tgt); + void AddItem(std::string const& item, cmTarget const* tgt); + void AddSharedDepItem(std::string const& item, cmTarget const* tgt); // Output information. ItemVector Items; @@ -71,7 +71,7 @@ private: std::vector Depends; std::vector FrameworkPaths; std::vector RuntimeSearchPath; - std::set SharedLibrariesLinked; + std::set SharedLibrariesLinked; // Context information. cmTarget const* Target; @@ -139,7 +139,7 @@ private: std::string NoCaseExpression(const char* str); // Handling of link items. - void AddTargetItem(std::string const& item, cmTarget* target); + void AddTargetItem(std::string const& item, cmTarget const* target); void AddFullItem(std::string const& item); bool CheckImplicitDirItem(std::string const& item); void AddUserItem(std::string const& item, bool pathNotKnown); @@ -179,7 +179,8 @@ private: // Runtime path computation. cmOrderDirectories* OrderRuntimeSearchPath; - void AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget* target); + void AddLibraryRuntimeInfo(std::string const& fullPath, + cmTarget const* target); void AddLibraryRuntimeInfo(std::string const& fullPath); // Dependent library path computation. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index f8b4e28..2a87e4f 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -402,7 +402,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, //---------------------------------------------------------------------------- -void getPropertyContents(cmTarget *tgt, const char *prop, +void getPropertyContents(cmTarget const* tgt, const char *prop, std::set &ifaceProperties) { const char *p = tgt->GetProperty(prop); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7b9109e..68f45a6 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -328,9 +328,10 @@ cmInstallTargetGenerator::GetInstallFilename(const char* config) const } //---------------------------------------------------------------------------- -std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target, - const char* config, - NameType nameType) +std::string +cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, + const char* config, + NameType nameType) { std::string fname; // Compute the name of the library. @@ -515,11 +516,12 @@ cmInstallTargetGenerator std::map install_name_remap; if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { - std::set const& sharedLibs = cli->GetSharedLibrariesLinked(); - for(std::set::const_iterator j = sharedLibs.begin(); + std::set const& sharedLibs + = cli->GetSharedLibrariesLinked(); + for(std::set::const_iterator j = sharedLibs.begin(); j != sharedLibs.end(); ++j) { - cmTarget* tgt = *j; + cmTarget const* tgt = *j; // The install_name of an imported target does not change. if(tgt->IsImported()) diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 8cf72f9..18c3957 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -53,7 +53,8 @@ public: NameReal }; - static std::string GetInstallFilename(cmTarget*target, const char* config, + static std::string GetInstallFilename(cmTarget const* target, + const char* config, NameType nameType = NameNormal); cmTarget* GetTarget() const { return this->Target; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 05b57a2..8628fd8 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5763,7 +5763,8 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, //---------------------------------------------------------------------------- template -void checkPropertyConsistency(cmTarget const* depender, cmTarget *dependee, +void checkPropertyConsistency(cmTarget const* depender, + cmTarget const* dependee, const char *propName, std::set &emitted, const char *config, -- cgit v0.12 From a54eeddaae8c30a6cdc71eb81d7f968147a7e4dc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 10 Dec 2013 15:44:39 +0100 Subject: Constify cmGeneratorTarget access. --- Source/cmGeneratorTarget.h | 2 +- Source/cmGlobalGenerator.cxx | 3 ++- Source/cmGlobalGenerator.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6aff5f0..8b760f1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -104,7 +104,7 @@ struct cmStrictTargetComparison { bool operator()(cmTarget const* t1, cmTarget const* t2) const; }; -typedef std::map cmGeneratorTargetsType; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 91a7594..e4a9246 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1432,7 +1432,8 @@ void cmGlobalGenerator::ClearGeneratorMembers() } //---------------------------------------------------------------------------- -cmGeneratorTarget* cmGlobalGenerator::GetGeneratorTarget(cmTarget* t) const +cmGeneratorTarget* +cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const { cmGeneratorTargetsType::const_iterator ti = this->GeneratorTargets.find(t); if(ti == this->GeneratorTargets.end()) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index e90af6c..b7bc475 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -269,7 +269,7 @@ public: TargetDependSet const& GetTargetDirectDepends(cmTarget const& target); /** Get per-target generator information. */ - cmGeneratorTarget* GetGeneratorTarget(cmTarget*) const; + cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const; const std::map >& GetProjectMap() const {return this->ProjectMap;} -- cgit v0.12 From 2fcafbf613f07d6b2484a1dfdb6ba7cd2fc4a645 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 10 Dec 2013 15:44:56 +0100 Subject: cmLocalGenerator: Constify target definitions access --- Source/cmLocalGenerator.cxx | 2 +- Source/cmLocalGenerator.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c3c5299..68d603a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1386,7 +1386,7 @@ std::string cmLocalGenerator::GetIncludeFlags( //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileDefinitions(std::set& defines, - cmTarget* target, + cmTarget const* target, const char* config) { std::vector targetDefines; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 9a89f0f..ad662d5 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -224,8 +224,9 @@ public: bool stripImplicitInclDirs = true); void AddCompileOptions(std::string& flags, cmTarget* target, const char* lang, const char* config); - void AddCompileDefinitions(std::set& defines, cmTarget* target, - const char* config); + void AddCompileDefinitions(std::set& defines, + cmTarget const* target, + const char* config); /** Compute the language used to compile the given source file. */ const char* GetSourceFileLanguage(const cmSourceFile& source); -- cgit v0.12 From 035b6908829f524936a6819a342cdff145708529 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 10 Dec 2013 15:53:00 +0100 Subject: Autogen: Split AutoRcc handling into two methods The initialize method changes the target, whereas the setup method does not. --- Source/cmQtAutoGenerators.cxx | 56 +++++++++++++++++++++++++++---------------- Source/cmQtAutoGenerators.h | 1 + 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 835e3b4..1988c5d 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -221,6 +221,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) if (target->GetPropertyAsBool("AUTORCC")) { toolNames.push_back("rcc"); + this->InitializeAutoRccTarget(target); } std::string tools = toolNames[0]; @@ -801,14 +802,47 @@ void cmQtAutoGenerators::MergeRccOptions(std::vector &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } +void cmQtAutoGenerators::InitializeAutoRccTarget(cmTarget* target) +{ + cmMakefile *makefile = target->GetMakefile(); + + const std::vector& srcFiles = target->GetSourceFiles(); + + for(std::vector::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string ext = sf->GetExtension(); + if (ext == "qrc") + { + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath().c_str()); + bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); + + if (!skip) + { + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFile); + + std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); + rcc_output_file += "/qrc_" + basename + ".cpp"; + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + rcc_output_file.c_str(), false); + cmSourceFile* rccCppSource + = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); + target->AddSourceFile(rccCppSource); + } + } + } +} + void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) { std::string _rcc_files; const char* sepRccFiles = ""; cmMakefile *makefile = target->GetMakefile(); - std::vector newFiles; - const std::vector& srcFiles = target->GetSourceFiles(); std::string rccFileFiles; @@ -841,17 +875,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) _rcc_files += absFile; sepRccFiles = ";"; - std::string basename = cmsys::SystemTools:: - GetFilenameWithoutLastExtension(absFile); - - std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); - rcc_output_file += "/qrc_" + basename + ".cpp"; - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - rcc_output_file.c_str(), false); - cmSourceFile* rccCppSource - = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); - newFiles.push_back(rccCppSource); - if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS")) { std::vector optsVec; @@ -880,13 +903,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) } } - for(std::vector::const_iterator fileIt = newFiles.begin(); - fileIt != newFiles.end(); - ++fileIt) - { - target->AddSourceFile(*fileIt); - } - makefile->AddDefinition("_rcc_files", cmLocalGenerator::EscapeForCMake(_rcc_files.c_str()).c_str()); diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index e877f7d..0888ea4 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -33,6 +33,7 @@ private: std::map &configDefines); void SetupAutoUicTarget(cmTarget* target, std::map &configUicOptions); + void InitializeAutoRccTarget(cmTarget* target); void SetupAutoRccTarget(cmTarget* target); cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, -- cgit v0.12 From c62cd3e2aeb9ed7e3021bd9e5863294fd0441790 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 10 Dec 2013 15:45:27 +0100 Subject: Constify autogen handling. --- Source/cmGlobalGenerator.h | 3 ++- Source/cmQtAutoGenerators.cxx | 22 ++++++++++++---------- Source/cmQtAutoGenerators.h | 8 ++++---- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index b7bc475..f60d24d 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -334,7 +334,8 @@ protected: virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS(); bool CheckTargets(); - typedef std::vector > AutogensType; + typedef std::vector > AutogensType; void CreateQtAutoGeneratorsTargets(AutogensType& autogens); std::string SelectMakeProgram(const char* makeProgram, diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 1988c5d..2b4bb8a 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -138,14 +138,14 @@ cmQtAutoGenerators::cmQtAutoGenerators() } } -static std::string getAutogenTargetName(cmTarget *target) +static std::string getAutogenTargetName(cmTarget const* target) { std::string autogenTargetName = target->GetName(); autogenTargetName += "_automoc"; return autogenTargetName; } -static std::string getAutogenTargetDir(cmTarget *target) +static std::string getAutogenTargetDir(cmTarget const* target) { cmMakefile* makefile = target->GetMakefile(); std::string targetDir = makefile->GetCurrentOutputDirectory(); @@ -296,7 +296,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) return true; } -static void GetCompileDefinitionsAndDirectories(cmTarget *target, +static void GetCompileDefinitionsAndDirectories(cmTarget const* target, const char * config, std::string &incs, std::string &defs) @@ -304,10 +304,12 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target, cmMakefile* makefile = target->GetMakefile(); cmLocalGenerator* localGen = makefile->GetLocalGenerator(); std::vector includeDirs; - cmGeneratorTarget gtgt(target); + cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); // Get the include dirs for this target, without stripping the implicit // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667 - localGen->GetIncludeDirectories(includeDirs, >gt, "CXX", config, false); + localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false); const char* sep = ""; incs = ""; for(std::vector::const_iterator incDirIt = includeDirs.begin(); @@ -333,7 +335,7 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target, } } -void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) +void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) { cmMakefile* makefile = target->GetMakefile(); @@ -436,7 +438,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) } } -void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget* target, +void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, const std::string &autogenTargetName, std::map &configIncludes, std::map &configDefines) @@ -615,7 +617,7 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -static void GetUicOpts(cmTarget *target, const char * config, +static void GetUicOpts(cmTarget const* target, const char * config, std::string &optString) { std::vector opts; @@ -632,7 +634,7 @@ static void GetUicOpts(cmTarget *target, const char * config, } } -void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget* target, +void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, std::map &configUicOptions) { cmMakefile *makefile = target->GetMakefile(); @@ -837,7 +839,7 @@ void cmQtAutoGenerators::InitializeAutoRccTarget(cmTarget* target) } } -void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) +void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) { std::string _rcc_files; const char* sepRccFiles = ""; diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 0888ea4..80123d8 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -24,17 +24,17 @@ public: bool Run(const char* targetDirectory, const char *config); bool InitializeAutogenTarget(cmTarget* target); - void SetupAutoGenerateTarget(cmTarget* target); + void SetupAutoGenerateTarget(cmTarget const* target); private: - void SetupAutoMocTarget(cmTarget* target, + void SetupAutoMocTarget(cmTarget const* target, const std::string &autogenTargetName, std::map &configIncludes, std::map &configDefines); - void SetupAutoUicTarget(cmTarget* target, + void SetupAutoUicTarget(cmTarget const* target, std::map &configUicOptions); void InitializeAutoRccTarget(cmTarget* target); - void SetupAutoRccTarget(cmTarget* target); + void SetupAutoRccTarget(cmTarget const* target); cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, const char* targetDirectory); -- cgit v0.12