[cmake-commits] king committed cmIfCommand.cxx 1.77 1.78 cmMakefile.cxx 1.389 1.390 cmMakefile.h 1.202 1.203 cmVariableWatch.h 1.9 1.10

cmake-commits at cmake.org cmake-commits at cmake.org
Thu May 17 17:41:01 EDT 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv7135

Modified Files:
	cmIfCommand.cxx cmMakefile.cxx cmMakefile.h cmVariableWatch.h 
Log Message:
BUG: All variable accesses should produce watch callbacks, including IF(DEFINED <var>) ones.  Instead we define a new access type for IF(DEFINED) so that the error does not show up for backward compatibility variables.


Index: cmVariableWatch.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmVariableWatch.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- cmVariableWatch.h	11 Apr 2007 19:13:05 -0000	1.9
+++ cmVariableWatch.h	17 May 2007 21:40:59 -0000	1.10
@@ -55,6 +55,7 @@
     {
     VARIABLE_READ_ACCESS = 0,
     UNKNOWN_VARIABLE_READ_ACCESS,
+    UNKNOWN_VARIABLE_DEFINED_ACCESS,
     ALLOWED_UNKNOWN_VARIABLE_READ_ACCESS,
     VARIABLE_MODIFIED_ACCESS,
     VARIABLE_REMOVED_ACCESS,

Index: cmIfCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.cxx,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- cmIfCommand.cxx	17 May 2007 19:12:12 -0000	1.77
+++ cmIfCommand.cxx	17 May 2007 21:40:59 -0000	1.78
@@ -307,17 +307,18 @@
       if (*arg == "DEFINED" && argP1  != newArgs.end())
         {
         size_t argP1len = argP1->size();
+        bool bdef = false;
         if(argP1len > 4 && argP1->substr(0, 4) == "ENV{" &&
            argP1->operator[](argP1len-1) == '}')
           {
           std::string env = argP1->substr(4, argP1len-5);
-          def = cmSystemTools::GetEnv(env.c_str());
+          bdef = cmSystemTools::GetEnv(env.c_str())?true:false;
           }
         else
           {
-          def = makefile->GetDefinitionNoWatch((argP1)->c_str());
+          bdef = makefile->IsDefinitionSet((argP1)->c_str());
           }
-        if(def)
+        if(bdef)
           {
           *arg = "1";
           }

Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.202
retrieving revision 1.203
diff -u -d -r1.202 -r1.203
--- cmMakefile.h	17 May 2007 19:12:13 -0000	1.202
+++ cmMakefile.h	17 May 2007 21:40:59 -0000	1.203
@@ -492,9 +492,9 @@
    * cache is then queried.
    */
   const char* GetDefinition(const char*) const;
-  const char* GetDefinitionNoWatch(const char*) const;
   const char* GetSafeDefinition(const char*) const;
   const char* GetRequiredDefinition(const char* name) const;
+  bool IsDefinitionSet(const char*) const;
   /**
    * Get the list of all variables in the current space. If argument
    * cacheonly is specified and is greater than 0, then only cache

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.389
retrieving revision 1.390
diff -u -d -r1.389 -r1.390
--- cmMakefile.cxx	17 May 2007 19:12:13 -0000	1.389
+++ cmMakefile.cxx	17 May 2007 21:40:59 -0000	1.390
@@ -1633,7 +1633,7 @@
   return ret;
 }
 
-const char* cmMakefile::GetDefinitionNoWatch(const char* name) const
+bool cmMakefile::IsDefinitionSet(const char* name) const
 {
   const char* def = 0;
   DefinitionMap::const_iterator pos = this->Definitions.find(name);
@@ -1645,12 +1645,32 @@
     {
     def = this->GetCacheManager()->GetCacheValue(name);
     }
-  return def;
+#ifdef CMAKE_BUILD_WITH_CMAKE
+  if(cmVariableWatch* vv = this->GetVariableWatch())
+    {
+    if(!def)
+      {
+      vv->VariableAccessed
+        (name, cmVariableWatch::UNKNOWN_VARIABLE_DEFINED_ACCESS,
+         def, this);
+      }
+    }
+#endif
+  return def?true:false;
 }
 
 const char* cmMakefile::GetDefinition(const char* name) const
 {
-  const char* def = this->GetDefinitionNoWatch(name);
+  const char* def = 0;
+  DefinitionMap::const_iterator pos = this->Definitions.find(name);
+  if(pos != this->Definitions.end())
+    {
+    def = (*pos).second.c_str();
+    }
+  else
+    {
+    def = this->GetCacheManager()->GetCacheValue(name);
+    }
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
   if ( vv )



More information about the Cmake-commits mailing list