From beee79373222ea01008cd137dd9a3ffa59cbe347 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Jul 2015 14:49:04 -0400 Subject: [PATCH] cmCommonTargetGenerator: Adopt GetFeature and friends De-duplicate the GetFeature, GetFeatureAsBool, and AddFeatureFlags members from the Makefile and Ninja target generators. --- Source/cmCommonTargetGenerator.cxx | 26 ++++++++++++++++++++++++++ Source/cmCommonTargetGenerator.h | 8 ++++++++ Source/cmMakefileTargetGenerator.cxx | 26 -------------------------- Source/cmMakefileTargetGenerator.h | 7 ------- Source/cmNinjaTargetGenerator.cxx | 26 -------------------------- Source/cmNinjaTargetGenerator.h | 4 ---- 6 files changed, 34 insertions(+), 63 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 3edeff347..34982b098 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -35,3 +35,29 @@ std::string const& cmCommonTargetGenerator::GetConfigName() const { return this->ConfigName; } + +//---------------------------------------------------------------------------- +const char* cmCommonTargetGenerator::GetFeature(const std::string& feature) +{ + return this->GeneratorTarget->GetFeature(feature, this->ConfigName); +} + +//---------------------------------------------------------------------------- +bool cmCommonTargetGenerator::GetFeatureAsBool(const std::string& feature) +{ + return this->GeneratorTarget->GetFeatureAsBool(feature, this->ConfigName); +} + +//---------------------------------------------------------------------------- +void cmCommonTargetGenerator::AddFeatureFlags( + std::string& flags, const std::string& lang + ) +{ + // Add language-specific flags. + this->LocalGenerator->AddLanguageFlags(flags, lang, this->ConfigName); + + if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION")) + { + this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO"); + } +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index bf2add39a..25d19a0f0 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -32,6 +32,14 @@ public: std::string const& GetConfigName() const; protected: + + // Add language feature flags. + void AddFeatureFlags(std::string& flags, const std::string& lang); + + // Feature query methods. + const char* GetFeature(const std::string& feature); + bool GetFeatureAsBool(const std::string& feature); + cmGeneratorTarget* GeneratorTarget; cmTarget* Target; cmMakefile* Makefile; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5c9402edd..42fb89c3b 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -2099,29 +2099,3 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) flag += (this->LocalGenerator->ConvertToLinkReference(def)); this->LocalGenerator->AppendFlags(flags, flag); } - -//---------------------------------------------------------------------------- -const char* cmMakefileTargetGenerator::GetFeature(const std::string& feature) -{ - return this->GeneratorTarget->GetFeature(feature, this->ConfigName); -} - -//---------------------------------------------------------------------------- -bool cmMakefileTargetGenerator::GetFeatureAsBool(const std::string& feature) -{ - return this->GeneratorTarget->GetFeatureAsBool(feature, this->ConfigName); -} - -//---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::AddFeatureFlags( - std::string& flags, const std::string& lang - ) -{ - // Add language-specific flags. - this->LocalGenerator->AddLanguageFlags(flags, lang, this->ConfigName); - - if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION")) - { - this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO"); - } -} diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 2985f4e7c..541542313 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -258,13 +258,6 @@ protected: // Helper to add flag for windows .def file. void AddModuleDefinitionFlag(std::string& flags); - // Add language feature flags. - void AddFeatureFlags(std::string& flags, const std::string& lang); - - // Feature query methods. - const char* GetFeature(const std::string& feature); - bool GetFeatureAsBool(const std::string& feature); - //================================================================== // Convenience routines that do nothing more than forward to // implementaitons diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 152bf7c26..8bc0ad0a9 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -96,32 +96,6 @@ std::string cmNinjaTargetGenerator::LanguageCompilerRule( cmGlobalNinjaGenerator::EncodeRuleName(this->Target->GetName()); } -// TODO: Picked up from cmMakefileTargetGenerator. Refactor it. -const char* cmNinjaTargetGenerator::GetFeature(const std::string& feature) -{ - return this->GeneratorTarget->GetFeature(feature, this->GetConfigName()); -} - -// TODO: Picked up from cmMakefileTargetGenerator. Refactor it. -bool cmNinjaTargetGenerator::GetFeatureAsBool(const std::string& feature) -{ - return this->GeneratorTarget->GetFeatureAsBool(feature, - this->GetConfigName()); -} - -// TODO: Picked up from cmMakefileTargetGenerator. Refactor it. -void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags, - const std::string& lang) -{ - // Add language-specific flags. - this->LocalGenerator->AddLanguageFlags(flags, lang, this->GetConfigName()); - - if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION")) - { - this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO"); - } -} - std::string cmNinjaTargetGenerator::OrderDependsTargetForTarget() { diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index e4468765d..639654a75 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -69,10 +69,6 @@ protected: std::string LanguageCompilerRule(const std::string& lang) const; - const char* GetFeature(const std::string& feature); - bool GetFeatureAsBool(const std::string& feature); - void AddFeatureFlags(std::string& flags, const std::string& lang); - std::string OrderDependsTargetForTarget(); std::string ComputeOrderDependsForTarget();