[cmake-commits] king committed cmGlobalGenerator.cxx 1.198 1.199 cmGlobalGenerator.h 1.90 1.91 cmGlobalUnixMakefileGenerator3.cxx 1.113 1.114 cmGlobalUnixMakefileGenerator3.h 1.47 1.48 cmMakefile.cxx 1.408 1.409 cmTarget.cxx 1.159 1.160

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Aug 3 15:44:27 EDT 2007


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

Modified Files:
	cmGlobalGenerator.cxx cmGlobalGenerator.h 
	cmGlobalUnixMakefileGenerator3.cxx 
	cmGlobalUnixMakefileGenerator3.h cmMakefile.cxx cmTarget.cxx 
Log Message:
BUG: Target exclusion-from-all tests should always use the root local generator associated with the all target being tested.


Index: cmGlobalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.h,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- cmGlobalGenerator.h	20 Jul 2007 12:36:16 -0000	1.90
+++ cmGlobalGenerator.h	3 Aug 2007 19:44:25 -0000	1.91
@@ -230,7 +230,8 @@
   // has been populated.
   void FillProjectMap();
   bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen);
-  void FillProjectToTargetMap();
+  bool IsExcluded(cmLocalGenerator* root, cmTarget& target);
+  void FillLocalGeneratorToTargetMap();
   void CreateDefaultGlobalTargets(cmTargets* targets);
   cmTarget CreateGlobalTarget(const char* name, const char* message,
     const cmCustomCommandLines* commandLines,
@@ -247,7 +248,7 @@
   cmLocalGenerator* CurrentLocalGenerator;
   // map from project name to vector of local generators in that project
   std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap;
-  std::map<cmStdString, std::set<cmTarget*> > ProjectToTargetMap;
+  std::map<cmLocalGenerator*, std::set<cmTarget*> > LocalGeneratorToTargetMap;
 
   // Set of named installation components requested by the project.
   std::set<cmStdString> InstallComponents;

Index: cmGlobalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalUnixMakefileGenerator3.cxx,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- cmGlobalUnixMakefileGenerator3.cxx	3 Aug 2007 13:39:32 -0000	1.113
+++ cmGlobalUnixMakefileGenerator3.cxx	3 Aug 2007 19:44:25 -0000	1.114
@@ -229,19 +229,7 @@
     {
     lg = 
       static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
-    // are any parents excluded
-    bool exclude = false;
-    cmLocalGenerator *lg3 = lg;
-    while (lg3)
-      {
-      if (lg3->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
-        {
-        exclude = true;
-        break;
-        }
-      lg3 = lg3->GetParent();
-      }
-    this->WriteConvenienceRules2(makefileStream,lg,exclude);
+    this->WriteConvenienceRules2(makefileStream,lg);
     }
 
   lg = static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[0]);
@@ -699,8 +687,7 @@
 void
 cmGlobalUnixMakefileGenerator3
 ::WriteConvenienceRules2(std::ostream& ruleFileStream, 
-                         cmLocalUnixMakefileGenerator3 *lg,
-                         bool exclude)
+                         cmLocalUnixMakefileGenerator3 *lg)
 {
   std::vector<std::string> depends;  
   std::vector<std::string> commands;
@@ -792,7 +779,7 @@
                         localName.c_str(), depends, commands, true);
       
       // add the all/all dependency
-      if (!exclude && !t->second.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
+      if(!this->IsExcluded(this->LocalGenerators[0], t->second))
         {
         depends.clear();
         depends.push_back(localName);
@@ -861,11 +848,15 @@
         lg->WriteMakeRule(ruleFileStream, 
                           "Pre-install relink rule for target.",
                           localName.c_str(), depends, commands, true);
-        depends.clear();
-        depends.push_back(localName);
-        commands.clear();
-        lg->WriteMakeRule(ruleFileStream, "Prepare target for install.",
-                          "preinstall", depends, commands, true);
+
+        if(!this->IsExcluded(this->LocalGenerators[0], t->second))
+          {
+          depends.clear();
+          depends.push_back(localName);
+          commands.clear();
+          lg->WriteMakeRule(ruleFileStream, "Prepare target for install.",
+                            "preinstall", depends, commands, true);
+          }
         }
       
       // add the clean rule
@@ -917,89 +908,16 @@
 ::GetNumberOfProgressActionsInAll(cmLocalUnixMakefileGenerator3 *lg)
 {
   unsigned long result = 0;
-
-  // if this is a project
-  if (!lg->GetParent() || 
-      strcmp(lg->GetMakefile()->GetProjectName(), 
-             lg->GetParent()->GetMakefile()->GetProjectName()))
-    {
-    // use the new project to target map   
-    std::set<cmTarget*> &targets = 
-      this->ProjectToTargetMap[lg->GetMakefile()->GetProjectName()];
-    std::set<cmTarget*>::iterator t = targets.begin();
-    for(; t != targets.end(); ++t)
-      {
-      cmTarget* target = *t;
-      cmLocalUnixMakefileGenerator3 *lg3 = 
-        static_cast<cmLocalUnixMakefileGenerator3 *>
-        (target->GetMakefile()->GetLocalGenerator());
-      std::vector<int> &progFiles = lg3->ProgressFiles[target->GetName()];
-      result += static_cast<unsigned long>(progFiles.size());
-      }
-    }
-  // for subdirectories
-  else
+  std::set<cmTarget*>& targets = this->LocalGeneratorToTargetMap[lg];
+  for(std::set<cmTarget*>::iterator t = targets.begin();
+      t != targets.end(); ++t)
     {
-    std::deque<cmLocalUnixMakefileGenerator3 *> lg3Stack;
-    lg3Stack.push_back(lg);
-    std::vector<cmStdString> targetsInAll;
-    std::set<cmTarget *> targets;
-    while (lg3Stack.size())
-      {
-      cmLocalUnixMakefileGenerator3 *lg3 = lg3Stack.front();
-      lg3Stack.pop_front();
-      for(cmTargets::iterator l = lg3->GetMakefile()->GetTargets().begin();
-          l != lg3->GetMakefile()->GetTargets().end(); ++l)
-        {
-        if((l->second.GetType() == cmTarget::EXECUTABLE) ||
-           (l->second.GetType() == cmTarget::STATIC_LIBRARY) ||
-           (l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
-           (l->second.GetType() == cmTarget::MODULE_LIBRARY) ||
-           (l->second.GetType() == cmTarget::UTILITY))
-          {
-          // Add this to the list of depends rules in this directory.
-          if (!l->second.GetPropertyAsBool("EXCLUDE_FROM_ALL") && 
-              targets.find(&l->second) == targets.end())
-            {
-            std::deque<cmTarget *> activeTgts;
-            activeTgts.push_back(&(l->second));
-            // trace depth of target dependencies
-            while (activeTgts.size())
-              {
-              if (targets.find(activeTgts.front()) == targets.end())
-                {
-                targets.insert(activeTgts.front());
-                cmLocalUnixMakefileGenerator3 *lg4 = 
-                  static_cast<cmLocalUnixMakefileGenerator3 *>
-                  (activeTgts.front()->GetMakefile()->GetLocalGenerator());
-                std::vector<int> &progFiles2 = 
-                  lg4->ProgressFiles[activeTgts.front()->GetName()];
-                result += static_cast<unsigned long>(progFiles2.size());
-                std::vector<cmTarget *> deps2 = 
-                  this->GetTargetDepends(*activeTgts.front());
-                for (std::vector<cmTarget *>::const_iterator di = 
-                       deps2.begin(); di != deps2.end(); ++di)
-                  {
-                  activeTgts.push_back(*di);
-                  }
-                }
-              activeTgts.pop_front();
-              }
-            }
-          }
-        }
-      
-      // The directory-level rule depends on the directory-level
-      // rules of the subdirectories.
-      for(std::vector<cmLocalGenerator*>::iterator sdi = 
-            lg3->GetChildren().begin(); 
-          sdi != lg3->GetChildren().end(); ++sdi)
-        {
-        cmLocalUnixMakefileGenerator3* slg =
-          static_cast<cmLocalUnixMakefileGenerator3*>(*sdi);
-        lg3Stack.push_back(slg);
-        }
-      }
+    cmTarget* target = *t;
+    cmLocalUnixMakefileGenerator3 *lg3 =
+      static_cast<cmLocalUnixMakefileGenerator3 *>
+      (target->GetMakefile()->GetLocalGenerator());
+    std::vector<int> &progFiles = lg3->ProgressFiles[target->GetName()];
+    result += static_cast<unsigned long>(progFiles.size());
     }
   return result;
 }

Index: cmGlobalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -d -r1.198 -r1.199
--- cmGlobalGenerator.cxx	20 Jul 2007 12:36:16 -0000	1.198
+++ cmGlobalGenerator.cxx	3 Aug 2007 19:44:25 -0000	1.199
@@ -691,7 +691,7 @@
   this->TargetDependencies.clear();
   this->TotalTargets.clear();
   this->ImportedTotalTargets.clear();
-  this->ProjectToTargetMap.clear();
+  this->LocalGeneratorToTargetMap.clear();
   this->ProjectMap.clear();
 
   // start with this directory
@@ -779,11 +779,11 @@
     }
   // at this point this->LocalGenerators has been filled,
   // so create the map from project name to vector of local generators
-    this->FillProjectMap();
-  // now create project to target map
-  // This will make sure that targets have all the
-  // targets they depend on as part of the build.
-    this->FillProjectToTargetMap();
+  this->FillProjectMap();
+
+  // Create a map from local generator to the complete set of targets
+  // it builds by default.
+  this->FillLocalGeneratorToTargetMap();
 
   if ( !this->CMakeInstance->GetScriptMode() )
     {
@@ -1116,22 +1116,38 @@
 bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
                                    cmLocalGenerator* gen)
 {
-  if(gen == root)
+  if(!gen || gen == root)
     {
+    // No directory excludes itself.
     return false;
     }
-  cmLocalGenerator* cur = gen->GetParent();
-  while(cur && cur != root)
+
+  if(gen->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
     {
-    if(cur->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
-      {
-      return true;
-      }
-    cur = cur->GetParent();
+    // This directory is excluded from its parent.
+    return true;
     }
-  return gen->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL");
+
+  // This directory is included in its parent.  Check whether the
+  // parent is excluded.
+  return this->IsExcluded(root, gen->GetParent());
 }
 
+bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
+                                   cmTarget& target)
+{
+  if(target.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
+    {
+    // This target is excluded from its directory.
+    return true;
+    }
+  else
+    {
+    // This target is included in its directory.  Check whether the
+    // directory is excluded.
+    return this->IsExcluded(root, target.GetMakefile()->GetLocalGenerator());
+    }
+}
 
 void cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang)
 {
@@ -1176,88 +1192,40 @@
 }
 
 
-// Build a map that contains a the set of targets used by each project
-void cmGlobalGenerator::FillProjectToTargetMap()
+// Build a map that contains a the set of targets used by each local
+// generator directory level.
+void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
 {
-  // loop over each project in the build
-  for(std::map<cmStdString,
-        std::vector<cmLocalGenerator*> >::iterator m =
-        this->ProjectMap.begin();
-      m != this->ProjectMap.end(); ++m)
+  // Loop over all targets in all local generators.
+  for(std::vector<cmLocalGenerator*>::const_iterator
+        lgi = this->LocalGenerators.begin();
+      lgi != this->LocalGenerators.end(); ++lgi)
     {
-    std::vector<cmLocalGenerator*>& lgs = m->second;
-    if(lgs.size() == 0)
-      {
-      continue;
-      }
-    cmStdString const & projectName = m->first;
-    cmMakefile* projectMakefile = lgs[0]->GetMakefile();
-    // get the current EXCLUDE_FROM_ALL value from projectMakefile
-    const char* exclude = 0;
-    std::string excludeSave;
-    bool chain = false;
-    exclude =
-      projectMakefile->GetProperties().
-      GetPropertyValue("EXCLUDE_FROM_ALL",
-                       cmProperty::DIRECTORY, chain);
-    if(exclude)
-      {
-      excludeSave = exclude;
-      }
-    // Set EXCLUDE_FROM_ALL to FALSE for the top level makefile because
-    // in the current project nothing is excluded yet
-    projectMakefile->SetProperty("EXCLUDE_FROM_ALL", "FALSE");
-    // now loop over all cmLocalGenerators in this project and pull
-    // out all the targets that depend on each other, even if those
-    // targets come from a target that is excluded.
-    for(std::vector<cmLocalGenerator*>::iterator lg =
-          lgs.begin(); lg != lgs.end(); ++lg)
+    cmLocalGenerator* lg = *lgi;
+    cmMakefile* mf = lg->GetMakefile();
+    cmTargets& targets = mf->GetTargets();
+    for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
       {
-      cmMakefile* mf = (*lg)->GetMakefile();
-      cmTargets& targets = mf->GetTargets();
-      for(cmTargets::iterator t = targets.begin();
-          t != targets.end(); ++t)
+      cmTarget& target = t->second;
+
+      // Consider the directory containing the target and all its
+      // parents until something excludes the target.
+      for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, target);
+          clg = clg->GetParent())
         {
-        cmTarget& target = t->second;
-        // if the target is in all then add it to the project
-        if(!target.GetPropertyAsBool("EXCLUDE_FROM_ALL"))
-          {
-          // add this target to the project
-          this->ProjectToTargetMap[projectName].insert(&target);
-          // get the target's dependencies
-          std::vector<cmTarget *>& tgtdeps = this->GetTargetDepends(target);
-          this->ProjectToTargetMap[projectName].insert(tgtdeps.begin(),
-                                                       tgtdeps.end());
-          }
+        // This local generator includes the target.
+        std::set<cmTarget*>& targetSet =
+          this->LocalGeneratorToTargetMap[clg];
+        targetSet.insert(&target);
+
+        // Add dependencies of the included target.  An excluded
+        // target may still be included if it is a dependency of a
+        // non-excluded target.
+        std::vector<cmTarget *>& tgtdeps = this->GetTargetDepends(target);
+        targetSet.insert(tgtdeps.begin(), tgtdeps.end());
         }
       }
-    // Now restore the EXCLUDE_FROM_ALL property on the project top
-    // makefile
-    if(exclude)
-      {
-      exclude = excludeSave.c_str();
-      }
-    projectMakefile->SetProperty("EXCLUDE_FROM_ALL", exclude);
     }
-  // dump the map for debug purposes
-  // right now this map is not being used, but it was
-  // checked in to avoid constant conflicts.
-  // It is also the first step to creating sub projects
-  // that contain all of the targets they need.
-#if 0
-  std::map<cmStdString, std::set<cmTarget*> >::iterator i =
-    this->ProjectToTargetMap.begin();
-  for(; i != this->ProjectToTargetMap.end(); ++i)
-    {
-    std::cerr << i->first << "\n";
-    std::set<cmTarget*>::iterator t = i->second.begin();
-    for(; t != i->second.end(); ++t)
-      {
-      cmTarget* target = *t;
-      std::cerr << "\t" << target->GetName() << "\n";
-      }
-    }
-#endif
 }
 
 

Index: cmGlobalUnixMakefileGenerator3.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalUnixMakefileGenerator3.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- cmGlobalUnixMakefileGenerator3.h	3 Aug 2007 13:39:32 -0000	1.47
+++ cmGlobalUnixMakefileGenerator3.h	3 Aug 2007 19:44:25 -0000	1.48
@@ -145,10 +145,9 @@
 protected:
   void WriteMainMakefile2();
   void WriteMainCMakefile();
-  
-  void WriteConvenienceRules2(std::ostream& ruleFileStream, 
-                              cmLocalUnixMakefileGenerator3 *,
-                              bool exclude);
+
+  void WriteConvenienceRules2(std::ostream& ruleFileStream,
+                              cmLocalUnixMakefileGenerator3*);
 
   void WriteDirectoryRule2(std::ostream& ruleFileStream,
                            cmLocalUnixMakefileGenerator3* lg,

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -d -r1.159 -r1.160
--- cmTarget.cxx	2 Aug 2007 17:38:39 -0000	1.159
+++ cmTarget.cxx	3 Aug 2007 19:44:25 -0000	1.160
@@ -122,9 +122,9 @@
      "Exclude the target from the all target.",
      "A property on a target that indicates if the target is excluded "
      "from the default build target. If it is not, then with a Makefile "
-     "for example typing make will couse this target to be built as well. "
+     "for example typing make will cause this target to be built. "
      "The same concept applies to the default build of other generators.",
-     true);
+     false);
 
   cm->DefineProperty
     ("INSTALL_NAME_DIR", cmProperty::TARGET,

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.408
retrieving revision 1.409
diff -u -d -r1.408 -r1.409
--- cmMakefile.cxx	20 Jul 2007 12:48:32 -0000	1.408
+++ cmMakefile.cxx	3 Aug 2007 19:44:25 -0000	1.409
@@ -2847,10 +2847,10 @@
 
   cm->DefineProperty
     ("EXCLUDE_FROM_ALL", cmProperty::DIRECTORY,
-     "Exclude the target from the all target.",
-     "A property on a target that indicates if the target is excluded "
+     "Exclude the directory from the all target of its parent.",
+     "A property on a directory that indicates if its targets are excluded "
      "from the default build target. If it is not, then with a Makefile "
-     "for example typing make will couse this target to be built as well. "
+     "for example typing make will cause the targets to be built. "
      "The same concept applies to the default build of other generators.",
-     true);
+     false);
 }



More information about the Cmake-commits mailing list