[cmake-commits] martink committed cmDocumentVariables.cxx 1.5 1.6 cmMakefile.cxx 1.416 1.417 cmPropertyMap.cxx 1.9 1.10 cmake.cxx 1.328 1.329 cmake.h 1.92 1.93

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Nov 6 14:16:02 EST 2007


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

Modified Files:
	cmDocumentVariables.cxx cmMakefile.cxx cmPropertyMap.cxx 
	cmake.cxx cmake.h 
Log Message:
ENH: different way of testing properties


Index: cmake.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.h,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -d -r1.92 -r1.93
--- cmake.h	24 Oct 2007 18:43:10 -0000	1.92
+++ cmake.h	6 Nov 2007 19:16:00 -0000	1.93
@@ -320,11 +320,16 @@
   bool IsPropertyDefined(const char *name, cmProperty::ScopeType scope);
   bool IsPropertyChained(const char *name, cmProperty::ScopeType scope);
 
+  // record accesses of properties and variables
+  void RecordPropertyAccess(const char *name, cmProperty::ScopeType scope);
+  void ReportUndefinedPropertyAccesses(const char *filename);
+
   // Define the properties
   static void DefineProperties(cmake *cm);
 
 protected:
   cmPropertyMap Properties;
+  std::set<std::pair<cmStdString,cmProperty::ScopeType> > AccessedProperties;
 
   std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> 
   PropertyDefinitions;

Index: cmDocumentVariables.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentVariables.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cmDocumentVariables.cxx	31 Oct 2007 17:57:51 -0000	1.5
+++ cmDocumentVariables.cxx	6 Nov 2007 19:16:00 -0000	1.6
@@ -936,4 +936,46 @@
   cm->DefineProperty("CMAKE_MATCH_7", cmProperty::VARIABLE,0,0);  
   cm->DefineProperty("CMAKE_MATCH_8", cmProperty::VARIABLE,0,0);  
   cm->DefineProperty("CMAKE_MATCH_9", cmProperty::VARIABLE,0,0);  
+
+  cm->DefineProperty("CMAKE_<LANG>_COMPILER_ARG1", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_COMPILER_ENV_VAR", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_COMPILER_ID_RUN", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_COMPILER_LOADED", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_CREATE_ASSEMBLY_SOURCE", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_CREATE_PREPROCESSED_SOURCE", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_FLAGS", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_FLAGS_DEBUG_INIT", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_FLAGS_INIT", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_FLAGS_MINSIZEREL_INIT", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_FLAGS_RELEASE_INIT", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_FLAGS_RELWITHDEBINFO_INIT", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_INFORMATION_LOADED", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_LINK_EXECUTABLE", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_LINK_FLAGS", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_STANDARD_LIBRARIES", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_STANDARD_LIBRARIES_INIT", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_EXECUTABLE_SUFFIX_<LANG>", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_EXE_LINK_DYNAMIC_<LANG>_FLAGS", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_EXE_LINK_STATIC_<LANG>_FLAGS", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_GENERATOR_<LANG>", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_IMPORT_LIBRARY_PREFIX_<LANG>", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_IMPORT_LIBRARY_SUFFIX_<LANG>", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_INCLUDE_FLAG_<LANG>", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_INCLUDE_FLAG_SEP_<LANG>", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_INCLUDE_SYSTEM_FLAG_<LANG>", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_NEEDS_REQUIRES_STEP_<LANG>_FLAG", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_SHARED_LIBRARY_CREATE_<LANG>_FLAGS", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_SHARED_LIBRARY_<LANG>_FLAGS", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_SHARED_LIBRARY_LINK_<LANG>_FLAGS", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_<LANG>_FLAGS", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_SHARED_LIBRARY_LINK_STATIC_<LANG>_FLAGS", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_SHARED_LIBRARY_RUNTIME_<LANG>_FLAG", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_SHARED_LIBRARY_RUNTIME_<LANG>_FLAG_SEP", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_SHARED_MODULE_CREATE_<LANG>_FLAGS", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_SHARED_MODULE_<LANG>_FLAGS", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_SHARED_MODULE_LINK_DYNAMIC_<LANG>_FLAGS", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_SHARED_MODULE_LINK_STATIC_<LANG>_FLAGS", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_SHARED_MODULE_RUNTIME_<LANG>_FLAG", cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_SHARED_MODULE_RUNTIME_<LANG>_FLAG_SEP", cmProperty::VARIABLE,0,0);
+
 }

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.416
retrieving revision 1.417
diff -u -d -r1.416 -r1.417
--- cmMakefile.cxx	23 Oct 2007 14:40:49 -0000	1.416
+++ cmMakefile.cxx	6 Nov 2007 19:16:00 -0000	1.417
@@ -1217,13 +1217,10 @@
     }
 
 #ifdef CMAKE_STRICT
-  if (this->GetCMakeInstance() &&
-      !this->GetCMakeInstance()->IsPropertyDefined(name,cmProperty::VARIABLE))
+  if (this->GetCMakeInstance())
     {
-    std::string msg = "Variable ";
-    msg += name;
-    msg += " set yet not defined!";
-    cmSystemTools::Error(msg.c_str()); 
+    this->GetCMakeInstance()->
+      RecordPropertyAccess(name,cmProperty::VARIABLE);
     }
 #endif
 
@@ -1682,13 +1679,10 @@
 const char* cmMakefile::GetDefinition(const char* name) const
 {
 #ifdef CMAKE_STRICT
-  if (this->GetCMakeInstance() &&
-      !this->GetCMakeInstance()->IsPropertyDefined(name,cmProperty::VARIABLE))
+  if (this->GetCMakeInstance())
     {
-    std::string msg = "Variable ";
-    msg += name;
-    msg += " queried yet undefined!";
-    cmSystemTools::Error(msg.c_str()); 
+    this->GetCMakeInstance()->
+      RecordPropertyAccess(name,cmProperty::VARIABLE);
     }
 #endif
   const char* def = 0;

Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.328
retrieving revision 1.329
diff -u -d -r1.328 -r1.329
--- cmake.cxx	5 Nov 2007 19:34:36 -0000	1.328
+++ cmake.cxx	6 Nov 2007 19:16:00 -0000	1.329
@@ -2084,6 +2084,11 @@
     {
     return -1;
     }
+  if (this->GetProperty("REPORT_UNDEFINED_PROPERTIES"))
+    {
+    this->ReportUndefinedPropertyAccesses
+      (this->GetProperty("REPORT_UNDEFINED_PROPERTIES"));
+    }
   return 0;
 }
 
@@ -3034,6 +3039,14 @@
 void cmake::DefineProperties(cmake *cm)
 {
   cm->DefineProperty
+    ("REPORT_UNDEFINED_PROPERTIES", cmProperty::GLOBAL, 
+     "If set, report any undefined properties to this file.",
+     "If this property is set to a filename then when CMake runs "
+     "it will report any properties or variables that were accessed "
+     "but not defined into the filename specified in this property."
+     );
+
+  cm->DefineProperty
     ("TARGET_SUPPORTS_SHARED_LIBS", cmProperty::GLOBAL, 
      "Does the target platform support shared libraries.",
      "TARGET_SUPPORTS_SHARED_LIBS is a boolean specifying whether the target "
@@ -3104,6 +3117,90 @@
   return 0;
 }
 
+void cmake::RecordPropertyAccess(const char *name, 
+                                 cmProperty::ScopeType scope)
+{
+  this->AccessedProperties.insert
+    (std::pair<cmStdString,cmProperty::ScopeType>(name,scope));
+}
+
+void cmake::ReportUndefinedPropertyAccesses(const char *filename)
+{
+  FILE *progFile = fopen(filename,"w");
+  if (!progFile || !this->GlobalGenerator)
+    {
+    return;
+    }
+
+  // what are the enabled languages?
+  std::vector<std::string> enLangs;
+  this->GlobalGenerator->GetEnabledLanguages(enLangs);
+
+  // take all the defined properties and add definitions for all the enabled
+  // languages
+  std::set<std::pair<cmStdString,cmProperty::ScopeType> > aliasedProperties;
+  std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::iterator i;
+  i = this->PropertyDefinitions.begin();
+  for (;i != this->PropertyDefinitions.end(); ++i)
+    {
+    cmPropertyDefinitionMap::iterator j;
+    for (j = i->second.begin(); j != i->second.end(); ++j)
+      {
+      if (j->first.find("<LANG>"))
+        {
+        std::vector<std::string>::const_iterator k;
+        for (k = enLangs.begin(); k != enLangs.end(); ++k)
+          {
+          std::string tmp = j->first;
+          cmSystemTools::ReplaceString(tmp, "<LANG>", k->c_str());
+          // add alias
+          aliasedProperties.insert
+            (std::pair<cmStdString,cmProperty::ScopeType>(tmp,i->first));
+          }
+        }
+      }
+    }
+
+  std::set<std::pair<cmStdString,cmProperty::ScopeType> >::const_iterator ap;
+  ap = this->AccessedProperties.begin();
+  for (;ap != this->AccessedProperties.end(); ++ap)
+    {
+    if (!this->IsPropertyDefined(ap->first.c_str(),ap->second) &&
+        aliasedProperties.find(std::pair<cmStdString,cmProperty::ScopeType>
+                               (ap->first,ap->second)) == 
+        aliasedProperties.end())
+      {
+      const char *scopeStr = "";
+      switch (ap->second)
+        {
+        case cmProperty::TARGET: 
+          scopeStr = "TARGET";
+          break;
+        case cmProperty::SOURCE_FILE:
+          scopeStr = "SOURCE_FILE";
+        break;
+        case cmProperty::DIRECTORY:
+          scopeStr = "DIRECTORY";
+          break;
+        case cmProperty::TEST:
+          scopeStr = "TEST";
+          break;
+        case cmProperty::VARIABLE:
+          scopeStr = "VARIABLE";
+          break;
+        case cmProperty::CACHED_VARIABLE:
+          scopeStr = "CACHED_VARIABLE";
+          break;
+        default:
+          scopeStr = "unknown";
+        break;
+        }
+      fprintf(progFile,"%s with scope %s\n",ap->first.c_str(),scopeStr);
+      }
+    }
+  fclose(progFile);
+}
+
 bool cmake::IsPropertyDefined(const char *name, cmProperty::ScopeType scope)
 {
   return this->PropertyDefinitions[scope].IsPropertyDefined(name);

Index: cmPropertyMap.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPropertyMap.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- cmPropertyMap.cxx	16 Oct 2007 18:28:37 -0000	1.9
+++ cmPropertyMap.cxx	6 Nov 2007 19:16:00 -0000	1.10
@@ -51,38 +51,9 @@
     cmSystemTools::Error("CMakeInstance not set on a property map!"); 
     abort();
     }
-  else if (!this->CMakeInstance->IsPropertyDefined(name,scope))
+  else
     {
-    // is a property being queried without being defined first? If so then
-    // report it as we probably need to document it
-    std::string msg = "Property ";
-    msg += name;
-    msg += " set yet undefined on ";
-    switch (scope)
-      {
-      case cmProperty::TARGET: 
-        msg += "target.";
-        break;
-      case cmProperty::SOURCE_FILE:
-        msg += "source file.";
-        break;
-      case cmProperty::DIRECTORY:
-        msg += "directory.";
-        break;
-      case cmProperty::TEST:
-        msg += "test.";
-        break;
-      case cmProperty::VARIABLE:
-        msg += "variable.";
-        break;
-      case cmProperty::CACHED_VARIABLE:
-        msg += "cached variable.";
-        break;
-      default:
-        msg += "unknown.";
-        break;
-      }
-    cmSystemTools::Error(msg.c_str()); 
+    this->CMakeInstance->RecordPropertyAccess(name,scope);
     }
 #else
   (void)scope;
@@ -110,38 +81,9 @@
     cmSystemTools::Error("CMakeInstance not set on a property map!"); 
     abort();
     }
-  else if (!this->CMakeInstance->IsPropertyDefined(name,scope))
+  else
     {
-    // is a property being queried without being defined first? If so then
-    // report it as we probably need to document it
-    std::string msg = "Property ";
-    msg += name;
-    msg += " queried yet undefined on ";
-    switch (scope)
-      {
-      case cmProperty::TARGET: 
-        msg += "target.";
-        break;
-      case cmProperty::SOURCE_FILE:
-        msg += "source file.";
-        break;
-      case cmProperty::DIRECTORY:
-        msg += "directory.";
-        break;
-      case cmProperty::TEST:
-        msg += "test.";
-        break;
-      case cmProperty::VARIABLE:
-        msg += "variable.";
-        break;
-      case cmProperty::CACHED_VARIABLE:
-        msg += "cached variable.";
-        break;
-      default:
-        msg += "unknown.";
-        break;
-      }
-    cmSystemTools::Error(msg.c_str()); 
+    this->CMakeInstance->RecordPropertyAccess(name,scope);
     }
 #endif
 



More information about the Cmake-commits mailing list