[cmake-commits] alex committed cmGlobalGenerator.h 1.91 1.92 cmGlobalGenerator.cxx 1.200 1.201

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Aug 16 15:33:19 EDT 2007


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

Modified Files:
	cmGlobalGenerator.h cmGlobalGenerator.cxx 
Log Message:

ENH: move the code for the NOTFOUND checking into its own function, so
Configure() gets easier to overview
-improve the error message, now it also says in which directories and for
which targets the missing variables are used
-minor speedup: the include directories don't have to be checked per target,
per directory is enough

Alex



Index: cmGlobalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.h,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- cmGlobalGenerator.h	3 Aug 2007 19:44:25 -0000	1.91
+++ cmGlobalGenerator.h	16 Aug 2007 19:33:17 -0000	1.92
@@ -229,6 +229,7 @@
   // Fill the ProjectMap, this must be called after LocalGenerators 
   // has been populated.
   void FillProjectMap();
+  void CheckLocalGenerators();
   bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen);
   bool IsExcluded(cmLocalGenerator* root, cmTarget& target);
   void FillLocalGeneratorToTargetMap();

Index: cmGlobalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -d -r1.200 -r1.201
--- cmGlobalGenerator.cxx	7 Aug 2007 19:09:21 -0000	1.200
+++ cmGlobalGenerator.cxx	16 Aug 2007 19:33:17 -0000	1.201
@@ -716,67 +716,10 @@
     ("CMAKE_NUMBER_OF_LOCAL_GENERATORS", num,
      "number of local generators", cmCacheManager::INTERNAL);
 
-  std::set<cmStdString> notFoundMap;
-  // after it is all done do a ConfigureFinalPass
-  cmCacheManager* manager = 0;
-  for (i = 0; i < this->LocalGenerators.size(); ++i)
-    {
-    manager = this->LocalGenerators[i]->GetMakefile()->GetCacheManager();
-    this->LocalGenerators[i]->ConfigureFinalPass();
-    cmTargets & targets =
-      this->LocalGenerators[i]->GetMakefile()->GetTargets();
-    for (cmTargets::iterator l = targets.begin();
-         l != targets.end(); l++)
-      {
-      cmTarget::LinkLibraryVectorType libs = l->second.GetLinkLibraries();
-      for(cmTarget::LinkLibraryVectorType::iterator lib = libs.begin();
-          lib != libs.end(); ++lib)
-        {
-        if(lib->first.size() > 9 &&
-           cmSystemTools::IsNOTFOUND(lib->first.c_str()))
-          {
-          std::string varName = lib->first.substr(0, lib->first.size()-9);
-          notFoundMap.insert(varName);
-          }
-        }
-      std::vector<std::string>& incs =
-        this->LocalGenerators[i]->GetMakefile()->GetIncludeDirectories();
-
-      for( std::vector<std::string>::iterator lib = incs.begin();
-           lib != incs.end(); ++lib)
-        {
-        if(lib->size() > 9 &&
-           cmSystemTools::IsNOTFOUND(lib->c_str()))
-          {
-          std::string varName = lib->substr(0, lib->size()-9);
-          notFoundMap.insert(varName);
-          }
-        }
-      this->CMakeInstance->UpdateProgress
-        ("Configuring", 0.9f+0.1f*(i+1.0f)/this->LocalGenerators.size());
-      this->LocalGenerators[i]->GetMakefile()->CheckInfiniteLoops();
-      }
-    }
+  // check for link libraries and include directories containing "NOTFOUND"
+  // and for infinite loops
+  this->CheckLocalGenerators();
 
-  if(notFoundMap.size())
-    {
-    std::string notFoundVars;
-    for(std::set<cmStdString>::iterator ii = notFoundMap.begin();
-        ii != notFoundMap.end(); ++ii)
-      {
-      notFoundVars += *ii;
-      if(manager)
-        {
-        cmCacheManager::CacheIterator it =
-          manager->GetCacheIterator(ii->c_str());
-        if(it.GetPropertyAsBool("ADVANCED"))
-          {
-          notFoundVars += " (ADVANCED)";
-          }
-        }
-      notFoundVars += "\n";
-      }
-    }
   // at this point this->LocalGenerators has been filled,
   // so create the map from project name to vector of local generators
   this->FillProjectMap();
@@ -863,6 +806,91 @@
   this->CMakeInstance->UpdateProgress("Generating done", -1);
 }
 
+void cmGlobalGenerator::CheckLocalGenerators()
+{
+  std::map<cmStdString, cmStdString> notFoundMap;
+//  std::set<cmStdString> notFoundMap;
+  // after it is all done do a ConfigureFinalPass
+  cmCacheManager* manager = 0;
+  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
+    {
+    manager = this->LocalGenerators[i]->GetMakefile()->GetCacheManager();
+    this->LocalGenerators[i]->ConfigureFinalPass();
+    const cmTargets & targets =
+      this->LocalGenerators[i]->GetMakefile()->GetTargets();
+    for (cmTargets::const_iterator l = targets.begin();
+         l != targets.end(); l++)
+      {
+      const cmTarget::LinkLibraryVectorType& libs=l->second.GetLinkLibraries();
+      for(cmTarget::LinkLibraryVectorType::const_iterator lib = libs.begin();
+          lib != libs.end(); ++lib)
+        {
+        if(lib->first.size() > 9 &&
+           cmSystemTools::IsNOTFOUND(lib->first.c_str()))
+          {
+          std::string varName = lib->first.substr(0, lib->first.size()-9);
+          cmCacheManager::CacheIterator it =
+            manager->GetCacheIterator(varName.c_str());
+          if(it.GetPropertyAsBool("ADVANCED"))
+            {
+            varName += " (ADVANCED)";
+            }
+          std::string text = notFoundMap[varName];
+          text += "\n    linked by target \"";
+          text += l->second.GetName();
+          text += "\" in directory ";
+          text+=this->LocalGenerators[i]->GetMakefile()->GetCurrentDirectory();
+          notFoundMap[varName] = text;
+          }
+        }
+      }
+    const std::vector<std::string>& incs =
+      this->LocalGenerators[i]->GetMakefile()->GetIncludeDirectories();
+
+    for( std::vector<std::string>::const_iterator incDir = incs.begin();
+          incDir != incs.end(); ++incDir)
+      {
+      if(incDir->size() > 9 &&
+          cmSystemTools::IsNOTFOUND(incDir->c_str()))
+        {
+        std::string varName = incDir->substr(0, incDir->size()-9);
+        cmCacheManager::CacheIterator it =
+          manager->GetCacheIterator(varName.c_str());
+        if(it.GetPropertyAsBool("ADVANCED"))
+          {
+          varName += " (ADVANCED)";
+          }
+        std::string text = notFoundMap[varName];
+        text += "\n   used as include directory in directory ";
+        text += this->LocalGenerators[i]->GetMakefile()->GetCurrentDirectory();
+        notFoundMap[varName] = text;
+        }
+      }
+    this->CMakeInstance->UpdateProgress
+      ("Configuring", 0.9f+0.1f*(i+1.0f)/this->LocalGenerators.size());
+    this->LocalGenerators[i]->GetMakefile()->CheckInfiniteLoops();
+    }
+
+  if(notFoundMap.size())
+    {
+    std::string notFoundVars;
+    for(std::map<cmStdString, cmStdString>::const_iterator 
+        ii = notFoundMap.begin();
+        ii != notFoundMap.end(); 
+        ++ii)
+      {
+      notFoundVars += ii->first;
+      notFoundVars += ii->second;
+      notFoundVars += "\n";
+      }
+    cmSystemTools::Error("The following variables are used in this project, "
+                         "but they are set to NOTFOUND.\n"
+                         "Please set them or make sure they are set and "
+                         "tested correctly in the CMake files:\n",
+                         notFoundVars.c_str());
+    }
+}
+
 int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
                                   const char *projectName,
                                   const char *target,



More information about the Cmake-commits mailing list