瀏覽代碼

Fix support for OLD behavior of policy CMP0002

The commit "Cleanup make progress rule generation code" introduced a map
from target name to the progress.make file location.  Policy CMP0002's
OLD behavior allows duplicate target names in different directories, so
only one ends up with a progress.make file.  This commit fixes the map
to order by target name first and build directory second, restoring
support for duplicate target names.
Brad King 16 年之前
父節點
當前提交
0089f9cf8f
共有 2 個文件被更改,包括 21 次插入4 次删除
  1. 18 3
      Source/cmGlobalUnixMakefileGenerator3.cxx
  2. 3 1
      Source/cmGlobalUnixMakefileGenerator3.h

+ 18 - 3
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -750,7 +750,7 @@ cmGlobalUnixMakefileGenerator3
                                 cmLocalGenerator::FULL,
                                 cmLocalGenerator::SHELL);
         progCmd << " ";
-        std::vector<int> &progFiles = this->ProgressMap[t->first].Marks;
+        std::vector<int> &progFiles = this->ProgressMap[&t->second].Marks;
         for (std::vector<int>::iterator i = progFiles.begin();
               i != progFiles.end(); ++i)
           {
@@ -873,7 +873,7 @@ cmGlobalUnixMakefileGenerator3
   size_t count = 0;
   if(emitted.insert(target).second)
     {
-    count = this->ProgressMap[target->GetName()].Marks.size();
+    count = this->ProgressMap[target].Marks.size();
     TargetDependSet const& depends = this->GetTargetDirectDepends(*target);
     for(TargetDependSet::const_iterator di = depends.begin();
         di != depends.end(); ++di)
@@ -905,11 +905,26 @@ void
 cmGlobalUnixMakefileGenerator3::RecordTargetProgress(
   cmMakefileTargetGenerator* tg)
 {
-  TargetProgress& tp = this->ProgressMap[tg->GetTarget()->GetName()];
+  TargetProgress& tp = this->ProgressMap[tg->GetTarget()];
   tp.NumberOfActions = tg->GetNumberOfProgressActions();
   tp.VariableFile = tg->GetProgressFileNameFull();
 }
 
+//----------------------------------------------------------------------------
+bool
+cmGlobalUnixMakefileGenerator3::ProgressMapCompare
+::operator()(cmTarget* l, cmTarget* r)
+{
+  // Order by target name.
+  if(int c = strcmp(l->GetName(), r->GetName()))
+    {
+    return c < 0;
+    }
+  // Order duplicate targets by binary directory.
+  return strcmp(l->GetMakefile()->GetCurrentOutputDirectory(),
+                r->GetMakefile()->GetCurrentOutputDirectory()) < 0;
+}
+
 //----------------------------------------------------------------------------
 void
 cmGlobalUnixMakefileGenerator3::TargetProgress

+ 3 - 1
Source/cmGlobalUnixMakefileGenerator3.h

@@ -180,7 +180,9 @@ protected:
     std::vector<int> Marks;
     void WriteProgressVariables(unsigned long total, unsigned long& current);
   };
-  typedef std::map<cmStdString, TargetProgress> ProgressMapType;
+  struct ProgressMapCompare { bool operator()(cmTarget*,cmTarget*); };
+  typedef std::map<cmTarget*, TargetProgress,
+                   ProgressMapCompare> ProgressMapType;
   ProgressMapType ProgressMap;
 
   size_t CountProgressMarksInTarget(cmTarget* target,