From b9eb3cd1405d423bf0156fabc3340c396b1f308c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 10:22:12 +0200 Subject: [PATCH] cmGlobalGenerator: Move LG to target map to subclass. This is the only user. --- Source/cmGlobalGenerator.cxx | 44 ----------------------- Source/cmGlobalGenerator.h | 4 +-- Source/cmGlobalUnixMakefileGenerator3.cxx | 43 ++++++++++++++++++++++ Source/cmGlobalUnixMakefileGenerator3.h | 4 +++ 4 files changed, 48 insertions(+), 47 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 621f1d4b1..2dddc7dc1 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2117,50 +2117,6 @@ void cmGlobalGenerator::FillProjectMap() } } - -// Build a map that contains a the set of targets used by each local -// generator directory level. -void cmGlobalGenerator::FillLocalGeneratorToTargetMap() -{ - this->LocalGeneratorToTargetMap.clear(); - // Loop over all targets in all local generators. - for(std::vector::const_iterator - lgi = this->LocalGenerators.begin(); - lgi != this->LocalGenerators.end(); ++lgi) - { - cmLocalGenerator* lg = *lgi; - cmMakefile* mf = lg->GetMakefile(); - cmTargets const& targets = mf->GetTargets(); - for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) - { - cmTarget const& target = t->second; - - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); - - // Consider the directory containing the target and all its - // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); - clg = clg->GetParent()) - { - // This local generator includes the target. - std::set& targetSet = - this->LocalGeneratorToTargetMap[clg]; - targetSet.insert(gt); - - // Add dependencies of the included target. An excluded - // target may still be included if it is a dependency of a - // non-excluded target. - TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(gt); - for(TargetDependSet::const_iterator ti = tgtdeps.begin(); - ti != tgtdeps.end(); ++ti) - { - targetSet.insert(*ti); - } - } - } - } -} - cmMakefile* cmGlobalGenerator::FindMakefile(const std::string& start_dir) const { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index a13bede8f..86f52af6e 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,7 +398,7 @@ protected: void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; - void FillLocalGeneratorToTargetMap(); + virtual void FillLocalGeneratorToTargetMap() {} void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, const cmCustomCommandLines* commandLines, @@ -413,8 +413,6 @@ protected: cmMakefile* CurrentMakefile; // map from project name to vector of local generators in that project std::map > ProjectMap; - std::map > - LocalGeneratorToTargetMap; // Set of named installation components requested by the project. std::set InstallComponents; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 76d059ee2..255b59d94 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -917,6 +917,49 @@ cmGlobalUnixMakefileGenerator3 } } +// Build a map that contains a the set of targets used by each local +// generator directory level. +void cmGlobalUnixMakefileGenerator3::FillLocalGeneratorToTargetMap() +{ + this->LocalGeneratorToTargetMap.clear(); + // Loop over all targets in all local generators. + for(std::vector::const_iterator + lgi = this->LocalGenerators.begin(); + lgi != this->LocalGenerators.end(); ++lgi) + { + cmLocalGenerator* lg = *lgi; + cmMakefile* mf = lg->GetMakefile(); + cmTargets const& targets = mf->GetTargets(); + for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) + { + cmTarget const& target = t->second; + + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + + // Consider the directory containing the target and all its + // parents until something excludes the target. + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); + clg = clg->GetParent()) + { + // This local generator includes the target. + std::set& targetSet = + this->LocalGeneratorToTargetMap[clg]; + targetSet.insert(gt); + + // Add dependencies of the included target. An excluded + // target may still be included if it is a dependency of a + // non-excluded target. + TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(gt); + for(TargetDependSet::const_iterator ti = tgtdeps.begin(); + ti != tgtdeps.end(); ++ti) + { + targetSet.insert(*ti); + } + } + } + } +} + //---------------------------------------------------------------------------- size_t cmGlobalUnixMakefileGenerator3 diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index fc53fa802..de7d858b3 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -206,6 +206,10 @@ protected: private: virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; } virtual std::string GetEditCacheCommand() const; + + std::map > + LocalGeneratorToTargetMap; + virtual void FillLocalGeneratorToTargetMap(); }; #endif