Browse Source

ENH: Add method to get definition even if it does not exists

Andy Cedilnik 21 years ago
parent
commit
e09e1679ab
2 changed files with 11 additions and 0 deletions
  1. 10 0
      Source/cmMakefile.cxx
  2. 1 0
      Source/cmMakefile.h

+ 10 - 0
Source/cmMakefile.cxx

@@ -1378,6 +1378,16 @@ const char* cmMakefile::GetDefinition(const char* name) const
   return def;
 }
 
+const char* cmMakefile::GetSafeDefinition(const char* def) const
+{
+  const char* ret = this->GetDefinition(def);
+  if(!ret)
+    {
+    return "";
+    }
+  return ret;
+}
+
 std::vector<std::string> cmMakefile::GetDefinitions(int cacheonly /* = 0 */) const
 {
   std::map<std::string, int> definitions;

+ 1 - 0
Source/cmMakefile.h

@@ -502,6 +502,7 @@ public:
    * cache is then queried.
    */
   const char* GetDefinition(const char*) const;
+  const char* GetSafeDefinition(const char*) const;
 
   /**
    * Get the list of all variables in the current space. If argument