diff options
author | Brad King <brad.king@kitware.com> | 2009-10-02 17:52:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-10-02 17:52:01 (GMT) |
commit | 1e482435912f44e05b5e67f19b1bc14ff58a3169 (patch) | |
tree | c317a934a8bfba0b942f2e0041c8e2cd8de50040 | |
parent | 57df2abca804dd8e98d000441fc0035eef9d4829 (diff) | |
download | CMake-1e482435912f44e05b5e67f19b1bc14ff58a3169.zip CMake-1e482435912f44e05b5e67f19b1bc14ff58a3169.tar.gz CMake-1e482435912f44e05b5e67f19b1bc14ff58a3169.tar.bz2 |
Introduce "build feature" lookup framework
This creates cmTarget::GetFeature and cmMakefile::GetFeature methods to
query "build feature" properties. These methods handle local-to-global
scope and per-configuration property lookup. Specific build features
will be defined later.
-rw-r--r-- | Source/cmLocalGenerator.cxx | 20 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 4 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 25 | ||||
-rw-r--r-- | Source/cmMakefile.h | 2 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 12 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.h | 4 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 20 | ||||
-rw-r--r-- | Source/cmTarget.h | 2 |
8 files changed, 89 insertions, 0 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index ee55957..1d5aba4 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2083,6 +2083,26 @@ void cmLocalGenerator::AppendDefines(std::string& defines, } //---------------------------------------------------------------------------- +void cmLocalGenerator::AppendFeatureOptions( + std::string& flags, const char* lang, const char* feature) +{ + std::string optVar = "CMAKE_"; + optVar += lang; + optVar += "_COMPILE_OPTIONS_"; + optVar += feature; + if(const char* optionList = this->Makefile->GetDefinition(optVar.c_str())) + { + std::vector<std::string> options; + cmSystemTools::ExpandListArgument(optionList, options); + for(std::vector<std::string>::const_iterator oi = options.begin(); + oi != options.end(); ++oi) + { + this->AppendFlags(flags, this->EscapeForShell(oi->c_str()).c_str()); + } + } +} + +//---------------------------------------------------------------------------- std::string cmLocalGenerator::ConstructComment(const cmCustomCommand& cc, const char* default_comment) diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 840e5d3..d2082e4 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -149,6 +149,10 @@ public: void AppendDefines(std::string& defines, const char* defines_list, const char* lang); + /** Lookup and append options associated with a particular feature. */ + void AppendFeatureOptions(std::string& flags, const char* lang, + const char* feature); + /** Translate a dependency as given in CMake code to the name to appear in a generated build file. If the given name is that of a CMake target it will be transformed to the real output diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7aa1202..afe5324 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3311,6 +3311,31 @@ bool cmMakefile::GetPropertyAsBool(const char* prop) return cmSystemTools::IsOn(this->GetProperty(prop)); } +//---------------------------------------------------------------------------- +const char* cmMakefile::GetFeature(const char* feature, const char* config) +{ + // TODO: Define accumulation policy for features (prepend, append, replace). + // Currently we always replace. + if(config && *config) + { + std::string featureConfig = feature; + featureConfig += "_"; + featureConfig += cmSystemTools::UpperCase(config); + if(const char* value = this->GetProperty(featureConfig.c_str())) + { + return value; + } + } + if(const char* value = this->GetProperty(feature)) + { + return value; + } + if(cmLocalGenerator* parent = this->LocalGenerator->GetParent()) + { + return parent->GetMakefile()->GetFeature(feature, config); + } + return 0; +} cmTarget* cmMakefile::FindTarget(const char* name) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 485d9e2..cb180ba 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -793,6 +793,8 @@ public: const char *GetProperty(const char *prop, cmProperty::ScopeType scope); bool GetPropertyAsBool(const char *prop); + const char* GetFeature(const char* feature, const char* config); + // Get the properties cmPropertyMap &GetProperties() { return this->Properties; }; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 719aa50..e353c3d 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1762,6 +1762,18 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) } //---------------------------------------------------------------------------- +const char* cmMakefileTargetGenerator::GetFeature(const char* feature) +{ + return this->Target->GetFeature(feature, this->ConfigName); +} + +//---------------------------------------------------------------------------- +bool cmMakefileTargetGenerator::GetFeatureAsBool(const char* feature) +{ + return cmSystemTools::IsOn(this->GetFeature(feature)); +} + +//---------------------------------------------------------------------------- void cmMakefileTargetGenerator::AddFeatureFlags( std::string& flags, const char* lang ) diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index d72bdce..4ee2b39 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -223,6 +223,10 @@ protected: // Add language feature flags. void AddFeatureFlags(std::string& flags, const char* lang); + // Feature query methods. + const char* GetFeature(const char* feature); + bool GetFeatureAsBool(const char* feature); + //================================================================== // Convenience routines that do nothing more than forward to // implementaitons diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8510b59..9233a1d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2245,6 +2245,26 @@ void cmTarget::GetTargetVersion(bool soversion, } //---------------------------------------------------------------------------- +const char* cmTarget::GetFeature(const char* feature, const char* config) +{ + if(config && *config) + { + std::string featureConfig = feature; + featureConfig += "_"; + featureConfig += cmSystemTools::UpperCase(config); + if(const char* value = this->GetProperty(featureConfig.c_str())) + { + return value; + } + } + if(const char* value = this->GetProperty(feature)) + { + return value; + } + return this->Makefile->GetFeature(feature, config); +} + +//---------------------------------------------------------------------------- const char *cmTarget::GetProperty(const char* prop) { return this->GetProperty(prop, cmProperty::TARGET); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e0e258d..7f44bb5 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -232,6 +232,8 @@ public: bool GetPropertyAsBool(const char *prop); void CheckProperty(const char* prop, cmMakefile* context); + const char* GetFeature(const char* feature, const char* config); + bool IsImported() const {return this->IsImportedTarget;} /** The link interface specifies transitive library dependencies and |