Browse Source

cmTarget: Add GetFeatureAsBool method

Return the GetFeature method result converted to a boolean value.
Brad King 11 years ago
parent
commit
c2eeb08b06

+ 1 - 1
Source/cmMakefileTargetGenerator.cxx

@@ -2105,7 +2105,7 @@ const char* cmMakefileTargetGenerator::GetFeature(const std::string& feature)
 //----------------------------------------------------------------------------
 bool cmMakefileTargetGenerator::GetFeatureAsBool(const std::string& feature)
 {
-  return cmSystemTools::IsOn(this->GetFeature(feature));
+  return this->Target->GetFeatureAsBool(feature, this->ConfigName);
 }
 
 //----------------------------------------------------------------------------

+ 1 - 1
Source/cmNinjaTargetGenerator.cxx

@@ -105,7 +105,7 @@ const char* cmNinjaTargetGenerator::GetFeature(const std::string& feature)
 // TODO: Picked up from cmMakefileTargetGenerator.  Refactor it.
 bool cmNinjaTargetGenerator::GetFeatureAsBool(const std::string& feature)
 {
-  return cmSystemTools::IsOn(this->GetFeature(feature));
+  return this->Target->GetFeatureAsBool(feature, this->GetConfigName());
 }
 
 // TODO: Picked up from cmMakefileTargetGenerator.  Refactor it.

+ 7 - 0
Source/cmTarget.cxx

@@ -3180,6 +3180,13 @@ const char* cmTarget::GetFeature(const std::string& feature,
   return this->Makefile->GetFeature(feature, config);
 }
 
+//----------------------------------------------------------------------------
+bool cmTarget::GetFeatureAsBool(const std::string& feature,
+                                const std::string& config) const
+{
+  return cmSystemTools::IsOn(this->GetFeature(feature, config));
+}
+
 //----------------------------------------------------------------------------
 bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
 {

+ 2 - 0
Source/cmTarget.h

@@ -237,6 +237,8 @@ public:
 
   const char* GetFeature(const std::string& feature,
                          const std::string& config) const;
+  bool GetFeatureAsBool(const std::string& feature,
+                        const std::string& config) const;
 
   bool IsImported() const {return this->IsImportedTarget;}