diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index ff19eac639..8a3a6712a0 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -161,7 +161,7 @@ void cmComputeTargetDepends::CollectTargets() std::vector const& lgens = this->GlobalGenerator->GetLocalGenerators(); for (unsigned int i = 0; i < lgens.size(); ++i) { - const std::vector targets = + const std::vector& targets = lgens[i]->GetGeneratorTargets(); for (std::vector::const_iterator ti = targets.begin(); ti != targets.end(); ++ti) { diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 5b7b82762f..e7a8975992 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -296,8 +296,9 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( // and UTILITY targets for (std::vector::const_iterator lg = lgs.begin(); lg != lgs.end(); lg++) { - std::vector targets = (*lg)->GetGeneratorTargets(); - for (std::vector::iterator ti = targets.begin(); + const std::vector& targets = + (*lg)->GetGeneratorTargets(); + for (std::vector::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { std::string targetName = (*ti)->GetName(); switch ((*ti)->GetType()) { @@ -359,8 +360,9 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( for (std::vector::const_iterator lg = lgs.begin(); lg != lgs.end(); lg++) { cmMakefile* makefile = (*lg)->GetMakefile(); - std::vector targets = (*lg)->GetGeneratorTargets(); - for (std::vector::iterator ti = targets.begin(); + const std::vector& targets = + (*lg)->GetGeneratorTargets(); + for (std::vector::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { switch ((*ti)->GetType()) { case cmStateEnums::EXECUTABLE: diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index b478f34faf..96502d5761 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -292,8 +292,9 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile( for (std::vector::const_iterator lg = lgs.begin(); lg != lgs.end(); lg++) { cmMakefile* makefile = (*lg)->GetMakefile(); - std::vector targets = (*lg)->GetGeneratorTargets(); - for (std::vector::iterator ti = targets.begin(); + const std::vector& targets = + (*lg)->GetGeneratorTargets(); + for (std::vector::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { projectType = CollectSourceFiles(makefile, *ti, cFiles, otherFiles); } diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 2a6ce98a77..473af3792b 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -475,7 +475,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml) this->GlobalGenerator->GetLocalGenerators().begin(); lgIt != this->GlobalGenerator->GetLocalGenerators().end(); ++lgIt) { cmMakefile* makefile = (*lgIt)->GetMakefile(); - const std::vector targets = + const std::vector& targets = (*lgIt)->GetGeneratorTargets(); for (std::vector::const_iterator ti = targets.begin(); @@ -853,8 +853,9 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const for (std::vector::const_iterator it = this->GlobalGenerator->GetLocalGenerators().begin(); it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - std::vector targets = (*it)->GetGeneratorTargets(); - for (std::vector::iterator l = targets.begin(); + const std::vector& targets = + (*it)->GetGeneratorTargets(); + for (std::vector::const_iterator l = targets.begin(); l != targets.end(); ++l) { std::vector includeDirs; std::string config = mf->GetSafeDefinition("CMAKE_BUILD_TYPE"); @@ -910,7 +911,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const for (std::vector::const_iterator it = this->GlobalGenerator->GetLocalGenerators().begin(); it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - const std::vector targets = + const std::vector& targets = (*it)->GetGeneratorTargets(); std::string subdir = (*it)->ConvertToRelativePath( this->HomeOutputDirectory, (*it)->GetCurrentBinaryDirectory()); diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 373043309d..e3667740ac 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -115,7 +115,7 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, for (std::vector::const_iterator it = this->GlobalGenerator->GetLocalGenerators().begin(); it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - const std::vector targets = + const std::vector& targets = (*it)->GetGeneratorTargets(); std::string currentDir = (*it)->GetCurrentBinaryDirectory(); bool topLevel = (currentDir == (*it)->GetBinaryDirectory()); diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 1fd1418de9..a62a546f5f 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -185,8 +185,9 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( for (std::vector::const_iterator lg = lgs.begin(); lg != lgs.end(); lg++) { cmMakefile* makefile = (*lg)->GetMakefile(); - std::vector targets = (*lg)->GetGeneratorTargets(); - for (std::vector::iterator ti = targets.begin(); + const std::vector& targets = + (*lg)->GetGeneratorTargets(); + for (std::vector::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { std::string targetName = (*ti)->GetName(); switch ((*ti)->GetType()) { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 18d10c5b9b..85ba5ee894 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2594,9 +2594,9 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, continue; } // Get the targets in the makefile - std::vector tgts = (*i)->GetGeneratorTargets(); + const std::vector& tgts = (*i)->GetGeneratorTargets(); // loop over all the targets - for (std::vector::iterator l = tgts.begin(); + for (std::vector::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { cmGeneratorTarget* target = *l; if (this->IsRootOnlyTarget(target) && @@ -2789,9 +2789,9 @@ void cmGlobalGenerator::WriteSummary() cmGeneratedFileStream fout(fname.c_str()); for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { - std::vector tgts = + const std::vector& tgts = this->LocalGenerators[i]->GetGeneratorTargets(); - for (std::vector::iterator it = tgts.begin(); + for (std::vector::const_iterator it = tgts.begin(); it != tgts.end(); ++it) { if ((*it)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index e72c6e384a..85a14171e8 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -128,8 +128,9 @@ bool cmGlobalKdevelopGenerator::CreateFilelistFile( } // get all sources - std::vector targets = (*it)->GetGeneratorTargets(); - for (std::vector::iterator ti = targets.begin(); + const std::vector& targets = + (*it)->GetGeneratorTargets(); + for (std::vector::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { std::vector sources; cmGeneratorTarget* gt = *ti; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 23b3718dc2..e42bf2039b 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -382,8 +382,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefileLanguageRules( for (unsigned int i = 0; i < lGenerators.size(); ++i) { lg = static_cast(lGenerators[i]); // for all of out targets - std::vector tgts = lg->GetGeneratorTargets(); - for (std::vector::iterator l = tgts.begin(); + const std::vector& tgts = lg->GetGeneratorTargets(); + for (std::vector::const_iterator l = tgts.begin(); l != tgts.end(); l++) { if (((*l)->GetType() == cmStateEnums::EXECUTABLE) || ((*l)->GetType() == cmStateEnums::STATIC_LIBRARY) || @@ -414,8 +414,8 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2( // The directory-level rule should depend on the target-level rules // for all targets in the directory. std::vector depends; - std::vector targets = lg->GetGeneratorTargets(); - for (std::vector::iterator l = targets.begin(); + const std::vector& targets = lg->GetGeneratorTargets(); + for (std::vector::const_iterator l = targets.begin(); l != targets.end(); ++l) { cmGeneratorTarget* gtarget = *l; int type = gtarget->GetType(); @@ -547,8 +547,8 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules( for (i = 0; i < this->LocalGenerators.size(); ++i) { lg = static_cast(this->LocalGenerators[i]); // for each target Generate the rule files for each target. - std::vector targets = lg->GetGeneratorTargets(); - for (std::vector::iterator t = targets.begin(); + const std::vector& targets = lg->GetGeneratorTargets(); + for (std::vector::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* gtarget = *t; // Don't emit the same rule twice (e.g. two targets with the same @@ -629,8 +629,8 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( depends.push_back("cmake_check_build_system"); // for each target Generate the rule files for each target. - std::vector targets = lg->GetGeneratorTargets(); - for (std::vector::iterator t = targets.begin(); + const std::vector& targets = lg->GetGeneratorTargets(); + for (std::vector::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* gtarget = *t; int type = gtarget->GetType(); @@ -807,7 +807,7 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() this->LocalGenerators.begin(); lgi != this->LocalGenerators.end(); ++lgi) { cmLocalGenerator* lg = *lgi; - std::vector targets = lg->GetGeneratorTargets(); + const std::vector& targets = lg->GetGeneratorTargets(); for (std::vector::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* gt = *t; @@ -952,8 +952,9 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule( // the targets if (lg2 == lg || lg->IsRootMakefile()) { // for each target Generate the rule files for each target. - std::vector targets = lg2->GetGeneratorTargets(); - for (std::vector::iterator t = targets.begin(); + const std::vector& targets = + lg2->GetGeneratorTargets(); + for (std::vector::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* target = *t; cmStateEnums::TargetType type = target->GetType(); diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 7e953cef1c..015f887260 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -420,7 +420,8 @@ int cmGraphVizWriter::CollectAllTargets() for (std::vector::const_iterator lit = this->LocalGenerators.begin(); lit != this->LocalGenerators.end(); ++lit) { - std::vector targets = (*lit)->GetGeneratorTargets(); + const std::vector& targets = + (*lit)->GetGeneratorTargets(); for (std::vector::const_iterator it = targets.begin(); it != targets.end(); ++it) { const char* realTargetName = (*it)->GetName().c_str(); @@ -445,7 +446,8 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) for (std::vector::const_iterator lit = this->LocalGenerators.begin(); lit != this->LocalGenerators.end(); ++lit) { - std::vector targets = (*lit)->GetGeneratorTargets(); + const std::vector& targets = + (*lit)->GetGeneratorTargets(); for (std::vector::const_iterator it = targets.begin(); it != targets.end(); ++it) { const char* realTargetName = (*it)->GetName().c_str(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 2c5db10406..2c8157eff9 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -214,8 +214,8 @@ void cmLocalGenerator::TraceDependencies() this->GlobalGenerator->CreateEvaluationSourceFiles(*ci); } // Generate the rule files for each target. - std::vector targets = this->GetGeneratorTargets(); - for (std::vector::iterator t = targets.begin(); + const std::vector& targets = this->GetGeneratorTargets(); + for (std::vector::const_iterator t = targets.begin(); t != targets.end(); ++t) { if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; @@ -548,6 +548,8 @@ void cmLocalGenerator::GenerateInstallRules() void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt) { this->GeneratorTargets.push_back(gt); + this->GeneratorTargetSearchIndex.insert( + std::pair(gt->GetName(), gt)); this->GlobalGenerator->IndexGeneratorTarget(gt); } @@ -581,11 +583,10 @@ private: cmGeneratorTarget* cmLocalGenerator::FindLocalNonAliasGeneratorTarget( const std::string& name) const { - std::vector::const_iterator ti = - std::find_if(this->GeneratorTargets.begin(), this->GeneratorTargets.end(), - NamedGeneratorTargetFinder(name)); - if (ti != this->GeneratorTargets.end()) { - return *ti; + GeneratorTargetMap::const_iterator ti = + this->GeneratorTargetSearchIndex.find(name); + if (ti != this->GeneratorTargetSearchIndex.end()) { + return ti->second; } return CM_NULLPTR; } @@ -600,8 +601,8 @@ void cmLocalGenerator::ComputeTargetManifest() } // Add our targets to the manifest for each configuration. - std::vector targets = this->GetGeneratorTargets(); - for (std::vector::iterator t = targets.begin(); + const std::vector& targets = this->GetGeneratorTargets(); + for (std::vector::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* target = *t; if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { @@ -625,8 +626,8 @@ bool cmLocalGenerator::ComputeTargetCompileFeatures() } // Process compile features of all targets. - std::vector targets = this->GetGeneratorTargets(); - for (std::vector::iterator t = targets.begin(); + const std::vector& targets = this->GetGeneratorTargets(); + for (std::vector::const_iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* target = *t; for (std::vector::iterator ci = configNames.begin(); @@ -2121,8 +2122,8 @@ void cmLocalGenerator::GenerateTargetInstallRules( { // Convert the old-style install specification from each target to // an install generator and run it. - std::vector tgts = this->GetGeneratorTargets(); - for (std::vector::iterator l = tgts.begin(); + const std::vector& tgts = this->GetGeneratorTargets(); + for (std::vector::const_iterator l = tgts.begin(); l != tgts.end(); ++l) { if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 9f78be4650..9083c83dcc 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -16,6 +16,7 @@ #include "cmOutputConverter.h" #include "cmPolicies.h" #include "cmStateSnapshot.h" +#include "cm_unordered_map.hxx" #include "cmake.h" class cmComputeLinkInformation; @@ -353,8 +354,11 @@ protected: std::string::size_type ObjectPathMax; std::set ObjectMaxPathViolations; - std::set WarnCMP0063; + typedef CM_UNORDERED_MAP GeneratorTargetMap; + GeneratorTargetMap GeneratorTargetSearchIndex; std::vector GeneratorTargets; + + std::set WarnCMP0063; std::vector ImportedGeneratorTargets; std::vector OwnedImportedGeneratorTargets; std::map AliasTargets; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 266710cb1c..9fa3ca57ef 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -79,8 +79,8 @@ void cmLocalNinjaGenerator::Generate() } } - std::vector targets = this->GetGeneratorTargets(); - for (std::vector::iterator t = targets.begin(); + const std::vector& targets = this->GetGeneratorTargets(); + for (std::vector::const_iterator t = targets.begin(); t != targets.end(); ++t) { if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 9b9d22cf59..2d100212ac 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -116,10 +116,10 @@ void cmLocalUnixMakefileGenerator3::Generate() this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES"); // Generate the rule files for each target. - std::vector targets = this->GetGeneratorTargets(); + const std::vector& targets = this->GetGeneratorTargets(); cmGlobalUnixMakefileGenerator3* gg = static_cast(this->GlobalGenerator); - for (std::vector::iterator t = targets.begin(); + for (std::vector::const_iterator t = targets.begin(); t != targets.end(); ++t) { if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; @@ -172,8 +172,8 @@ void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames( void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles( std::map& localObjectFiles) { - std::vector targets = this->GetGeneratorTargets(); - for (std::vector::iterator ti = targets.begin(); + const std::vector& targets = this->GetGeneratorTargets(); + for (std::vector::const_iterator ti = targets.begin(); ti != targets.end(); ++ti) { cmGeneratorTarget* gt = *ti; if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { @@ -382,9 +382,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( // for each target we just provide a rule to cd up to the top and do a make // on the target - std::vector targets = this->GetGeneratorTargets(); + const std::vector& targets = this->GetGeneratorTargets(); std::string localName; - for (std::vector::iterator t = targets.begin(); + for (std::vector::const_iterator t = targets.begin(); t != targets.end(); ++t) { if (((*t)->GetType() == cmStateEnums::EXECUTABLE) || ((*t)->GetType() == cmStateEnums::STATIC_LIBRARY) || @@ -1562,8 +1562,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( this->WriteDivider(ruleFileStream); ruleFileStream << "# Targets provided globally by CMake.\n" << "\n"; - std::vector targets = this->GetGeneratorTargets(); - std::vector::iterator glIt; + const std::vector& targets = this->GetGeneratorTargets(); + std::vector::const_iterator glIt; for (glIt = targets.begin(); glIt != targets.end(); ++glIt) { if ((*glIt)->GetType() == cmStateEnums::GLOBAL_TARGET) { std::string targetString =