diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index b5f5ce9e7..9d5335ec5 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -51,6 +51,8 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, this->Makefile = makefile; + this->AliasTargets = makefile->GetAliasTargets(); + this->EmitUniversalBinaryFlags = true; this->BackwardsCompatibility = 0; this->BackwardsCompatibilityFinal = false; @@ -453,11 +455,45 @@ void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt) this->GeneratorTargets.push_back(gt); } +struct NamedGeneratorTargetFinder +{ + NamedGeneratorTargetFinder(std::string const& name) + : Name(name) + { + + } + + bool operator()(cmGeneratorTarget* tgt) + { + return tgt->GetName() == this->Name; + } +private: + std::string Name; +}; + cmGeneratorTarget* cmLocalGenerator::FindGeneratorTarget( const std::string& name) const { - return this->GetGlobalGenerator()->GetGeneratorTarget( - this->Makefile->FindTarget(name)); + std::map::const_iterator i = + this->AliasTargets.find(name); + if (i != this->AliasTargets.end()) + { + std::vector::const_iterator ai = + std::find_if(this->GeneratorTargets.begin(), + this->GeneratorTargets.end(), + NamedGeneratorTargetFinder(i->second)); + return *ai; + } + std::vector::const_iterator ti = + std::find_if(this->GeneratorTargets.begin(), + this->GeneratorTargets.end(), + NamedGeneratorTargetFinder(name)); + if ( ti != this->GeneratorTargets.end() ) + { + return *ti; + } + + return 0; } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 46eb1b391..91a476fa0 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -373,6 +373,7 @@ protected: std::set WarnCMP0063; std::vector GeneratorTargets; + std::map AliasTargets; bool EmitUniversalBinaryFlags; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 35dd3c659..01c452422 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -400,6 +400,11 @@ public: bool excludeAliases = false) const; bool IsAlias(const std::string& name) const; + std::map GetAliasTargets() const + { + return this->AliasTargets; + } + /** * Mark include directories as system directories. */