diff options
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 81 |
1 files changed, 20 insertions, 61 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 7ffd5af..848028f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1656,6 +1656,8 @@ void cmGlobalGenerator::ClearGeneratorMembers() this->ExportSets.clear(); this->TargetDependencies.clear(); + this->TargetSearchIndex.clear(); + this->GeneratorTargetSearchIndex.clear(); this->ProjectMap.clear(); this->RuleHashes.clear(); this->DirectoryContentMap.clear(); @@ -2184,75 +2186,40 @@ bool cmGlobalGenerator::IsAlias(const std::string& name) const return this->AliasTargets.find(name) != this->AliasTargets.end(); } -cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const +void cmGlobalGenerator::IndexTarget(cmTarget* t) { - for (unsigned int i = 0; i < this->Makefiles.size(); ++i) + if (!t->IsImported() || t->IsImportedGloballyVisible()) { - cmTargets& tgts = this->Makefiles[i]->GetTargets(); - for (cmTargets::iterator it = tgts.begin(); it != tgts.end(); ++it) - { - if (it->second.GetName() == name) - { - return &it->second; - } - } + this->TargetSearchIndex[t->GetName()] = t; } - return 0; } -cmGeneratorTarget* -cmGlobalGenerator::FindGeneratorTargetImpl(std::string const& name) const +void cmGlobalGenerator::IndexGeneratorTarget(cmGeneratorTarget* gt) { - for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) + if (!gt->IsImported() || gt->IsImportedGloballyVisible()) { - const std::vector<cmGeneratorTarget*>& tgts = - this->LocalGenerators[i]->GetGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::const_iterator it = tgts.begin(); - it != tgts.end(); ++it) - { - if ((*it)->GetName() == name) - { - return *it; - } - } + this->GeneratorTargetSearchIndex[gt->GetName()] = gt; } - return 0; } -cmTarget* -cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const +cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const { - for (unsigned int i = 0; i < this->Makefiles.size(); ++i) + TargetMap::const_iterator i = this->TargetSearchIndex.find(name); + if (i != this->TargetSearchIndex.end()) { - const std::vector<cmTarget*>& tgts = - this->Makefiles[i]->GetOwnedImportedTargets(); - for (std::vector<cmTarget*>::const_iterator it = tgts.begin(); - it != tgts.end(); ++it) - { - if ((*it)->GetName() == name && (*it)->IsImportedGloballyVisible()) - { - return *it; - } - } + return i->second; } return 0; } -cmGeneratorTarget* cmGlobalGenerator::FindImportedGeneratorTargetImpl( - std::string const& name) const +cmGeneratorTarget* +cmGlobalGenerator::FindGeneratorTargetImpl(std::string const& name) const { - for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) + GeneratorTargetMap::const_iterator i = + this->GeneratorTargetSearchIndex.find(name); + if (i != this->GeneratorTargetSearchIndex.end()) { - const std::vector<cmGeneratorTarget*>& tgts = - this->LocalGenerators[i]->GetImportedGeneratorTargets(); - for (std::vector<cmGeneratorTarget*>::const_iterator it = tgts.begin(); - it != tgts.end(); ++it) - { - if ((*it)->IsImportedGloballyVisible() && (*it)->GetName() == name) - { - return *it; - } - } + return i->second; } return 0; } @@ -2271,11 +2238,7 @@ cmGlobalGenerator::FindTarget(const std::string& name, return this->FindTargetImpl(ai->second); } } - if (cmTarget* tgt = this->FindTargetImpl(name)) - { - return tgt; - } - return this->FindImportedTargetImpl(name); + return this->FindTargetImpl(name); } cmGeneratorTarget* @@ -2287,11 +2250,7 @@ cmGlobalGenerator::FindGeneratorTarget(const std::string& name) const { return this->FindGeneratorTargetImpl(ai->second); } - if (cmGeneratorTarget* tgt = this->FindGeneratorTargetImpl(name)) - { - return tgt; - } - return this->FindImportedGeneratorTargetImpl(name); + return this->FindGeneratorTargetImpl(name); } //---------------------------------------------------------------------------- |