From 8caf1f361b2207522d19bf4a28cecaa3a2391918 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 25 Oct 2015 13:06:59 +0100 Subject: [PATCH] cmGlobalGenerator: Add FindGeneratorTarget API --- Source/cmGlobalGenerator.cxx | 48 ++++++++++++++++++++++++++++++++++++ Source/cmGlobalGenerator.h | 6 +++++ 2 files changed, 54 insertions(+) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6b5cb973c..5928fb5dd 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2196,6 +2196,25 @@ cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const return 0; } +cmGeneratorTarget* +cmGlobalGenerator::FindGeneratorTargetImpl(std::string const& name) const +{ + for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) + { + std::vector tgts = + this->LocalGenerators[i]->GetGeneratorTargets(); + for (std::vector::iterator it = tgts.begin(); + it != tgts.end(); ++it) + { + if ((*it)->GetName() == name) + { + return *it; + } + } + } + return 0; +} + cmTarget* cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const { @@ -2215,6 +2234,25 @@ cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const return 0; } +cmGeneratorTarget* cmGlobalGenerator::FindImportedGeneratorTargetImpl( + std::string const& name) const +{ + for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) + { + std::vector tgts = + this->LocalGenerators[i]->GetGeneratorTargets(); + for (std::vector::iterator it = tgts.begin(); + it != tgts.end(); ++it) + { + if ((*it)->GetName() == name && (*it)->IsImportedGloballyVisible()) + { + return *it; + } + } + } + return 0; +} + //---------------------------------------------------------------------------- cmTarget* cmGlobalGenerator::FindTarget(const std::string& name, @@ -2236,6 +2274,16 @@ cmGlobalGenerator::FindTarget(const std::string& name, return this->FindImportedTargetImpl(name); } +cmGeneratorTarget* +cmGlobalGenerator::FindGeneratorTarget(const std::string& name) const +{ + if (cmGeneratorTarget* tgt = this->FindGeneratorTargetImpl(name)) + { + return tgt; + } + return this->FindImportedGeneratorTargetImpl(name); +} + //---------------------------------------------------------------------------- bool cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 419cadaa9..c52b20996 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -254,6 +254,8 @@ public: cmTarget* FindTarget(const std::string& name, bool excludeAliases = false) const; + cmGeneratorTarget* FindGeneratorTarget(const std::string& name) const; + void AddAlias(const std::string& name, const std::string& tgtName); bool IsAlias(const std::string& name) const; @@ -432,6 +434,10 @@ protected: cmTarget* FindTargetImpl(std::string const& name) const; cmTarget* FindImportedTargetImpl(std::string const& name) const; + cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const; + cmGeneratorTarget* + FindImportedGeneratorTargetImpl(std::string const& name) const; + const char* GetPredefinedTargetsFolder(); virtual bool UseFolderProperty();