浏览代码

cmTarget: Add GetFeatureAsBool method

Return the GetFeature method result converted to a boolean value.
Brad King 11 年之前
父节点
当前提交
c2eeb08b06
共有 4 个文件被更改,包括 11 次插入2 次删除
  1. 1 1
      Source/cmMakefileTargetGenerator.cxx
  2. 1 1
      Source/cmNinjaTargetGenerator.cxx
  3. 7 0
      Source/cmTarget.cxx
  4. 2 0
      Source/cmTarget.h

+ 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;}