diff options
author | Brad King <brad.king@kitware.com> | 2014-01-13 15:25:32 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-01-13 15:25:32 (GMT) |
commit | 8d989d1788252066c18de99d6df004abaa888dda (patch) | |
tree | 6ccbdcb1373bd550f7dfe4a67e4ee6d2ab0ebd57 /Source/cmGlobalGenerator.cxx | |
parent | b003f56f8550614419f63c0c1530d7baa2871372 (diff) | |
parent | 2cbf031190e6b7981974e452c49dafd73dea4a4b (diff) | |
download | CMake-8d989d1788252066c18de99d6df004abaa888dda.zip CMake-8d989d1788252066c18de99d6df004abaa888dda.tar.gz CMake-8d989d1788252066c18de99d6df004abaa888dda.tar.bz2 |
Merge topic 'constify'
2cbf0311 cmGlobalGenerator: Make SelectMakeProgram const.
b4ff38a5 cmGlobalGenerator: Make CheckALLOW_DUPLICATE_CUSTOM_TARGETS const
8aeddf1f cmGlobalGenerator: Make some API const.
8fd0f2a7 cmGeneratorTarget: Hold a const global generator.
46315320 cmComputeLinkDepends: Hold a const global generator.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 84 |
1 files changed, 50 insertions, 34 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 5a6b9b0..8a7eee4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -90,7 +90,7 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts) } std::string cmGlobalGenerator::SelectMakeProgram(const char* makeProgram, - std::string makeDefault) + std::string makeDefault) const { if(cmSystemTools::IsOff(makeProgram)) { @@ -111,7 +111,7 @@ std::string cmGlobalGenerator::SelectMakeProgram(const char* makeProgram, void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, cmMakefile *mf, - bool optional) + bool optional) const { std::string langComp = "CMAKE_"; langComp += lang; @@ -723,7 +723,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, //---------------------------------------------------------------------------- void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os, std::string lang, - const char* envVar) + const char* envVar) const { // Subclasses override this method if they do not support this advice. os << @@ -744,7 +744,7 @@ void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os, //---------------------------------------------------------------------------- void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, - std::string lang) + std::string lang) const { std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID"; const char* compilerId = mf->GetDefinition(compilerIdVar.c_str()); @@ -782,13 +782,16 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, //---------------------------------------------------------------------------- const char* -cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) +cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const { if(const char* lang = source.GetLanguage()) { - if(this->LanguageToOutputExtension.count(lang) > 0) + std::map<cmStdString, cmStdString>::const_iterator it = + this->LanguageToOutputExtension.find(lang); + + if(it != this->LanguageToOutputExtension.end()) { - return this->LanguageToOutputExtension[lang].c_str(); + return it->second.c_str(); } } else @@ -809,7 +812,7 @@ cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) } -const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) +const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const { // if there is an extension and it starts with . then move past the // . because the extensions are not stored with a . in the map @@ -817,9 +820,11 @@ const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) { ++ext; } - if(this->ExtensionToLanguage.count(ext) > 0) + std::map<cmStdString, cmStdString>::const_iterator it + = this->ExtensionToLanguage.find(ext); + if(it != this->ExtensionToLanguage.end()) { - return this->ExtensionToLanguage[ext].c_str(); + return it->second.c_str(); } return 0; } @@ -943,7 +948,7 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const char* l, } } -bool cmGlobalGenerator::IgnoreFile(const char* l) +bool cmGlobalGenerator::IgnoreFile(const char* l) const { if(this->GetLanguageFromExtension(l)) { @@ -966,15 +971,22 @@ bool cmGlobalGenerator::IsDependedOn(const char* project, cmTarget const* targetIn) { // Get all local gens for this project - std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project]; + std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator it = + this->ProjectMap.find(project); + if (it == this->ProjectMap.end()) + { + return false; + } + // loop over local gens and get the targets for each one - for(unsigned int i = 0; i < gens->size(); ++i) + for(std::vector<cmLocalGenerator*>::const_iterator geIt = it->second.begin(); + geIt != it->second.end(); ++geIt) { - cmTargets& targets = (*gens)[i]->GetMakefile()->GetTargets(); - for (cmTargets::iterator l = targets.begin(); + cmTargets const& targets = (*geIt)->GetMakefile()->GetTargets(); + for (cmTargets::const_iterator l = targets.begin(); l != targets.end(); l++) { - cmTarget& target = l->second; + cmTarget const& target = l->second; TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(target); if(tgtdeps.count(targetIn)) { @@ -1064,7 +1076,7 @@ void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target) this->CMP0042WarnTargets.insert(target); } -bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() +bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { // If the property is not enabled then okay. if(!this->CMakeInstance @@ -1899,7 +1911,7 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmLocalGenerator* gen) + cmLocalGenerator* gen) const { if(!gen || gen == root) { @@ -1919,7 +1931,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget& target) + cmTarget const& target) const { if(target.GetType() == cmTarget::INTERFACE_LIBRARY || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) @@ -1935,16 +1947,17 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } } -void cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) +void +cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const { - for(std::map<cmStdString, bool>::iterator i = + for(std::map<cmStdString, bool>::const_iterator i = this->LanguageEnabled.begin(); i != this->LanguageEnabled.end(); ++i) { lang.push_back(i->first); } } -int cmGlobalGenerator::GetLinkerPreference(const char* lang) +int cmGlobalGenerator::GetLinkerPreference(const char* lang) const { std::map<cmStdString, int>::const_iterator it = this->LanguageToLinkerPreference.find(lang); @@ -1990,10 +2003,10 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmLocalGenerator* lg = *lgi; cmMakefile* mf = lg->GetMakefile(); - cmTargets& targets = mf->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + cmTargets const& targets = mf->GetTargets(); + for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) { - cmTarget& target = t->second; + cmTarget const& target = t->second; // Consider the directory containing the target and all its // parents until something excludes the target. @@ -2022,15 +2035,16 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() ///! Find a local generator by its startdirectory -cmLocalGenerator* cmGlobalGenerator::FindLocalGenerator(const char* start_dir) +cmLocalGenerator* +cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const { - std::vector<cmLocalGenerator*>* gens = &this->LocalGenerators; - for(unsigned int i = 0; i < gens->size(); ++i) + for(std::vector<cmLocalGenerator*>::const_iterator it = + this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it) { - std::string sd = (*gens)[i]->GetMakefile()->GetStartDirectory(); + std::string sd = (*it)->GetMakefile()->GetStartDirectory(); if (sd == start_dir) { - return (*gens)[i]; + return *it; } } return 0; @@ -2513,11 +2527,13 @@ cmGlobalGenerator::GenerateRuleFile(std::string const& output) const //---------------------------------------------------------------------------- std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage( - std::string const& l) + std::string const& l) const { - if(this->LanguageToOriginalSharedLibFlags.count(l) > 0) + std::map<cmStdString, cmStdString>::const_iterator it = + this->LanguageToOriginalSharedLibFlags.find(l); + if(it != this->LanguageToOriginalSharedLibFlags.end()) { - return this->LanguageToOriginalSharedLibFlags[l]; + return it->second; } return ""; } @@ -2648,7 +2664,7 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) +bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const { return (target->GetType() == cmTarget::GLOBAL_TARGET || strcmp(target->GetName(), this->GetAllTargetName()) == 0); |