[cmake-commits] alex committed cmLocalVisualStudioGenerator.cxx 1.12 1.13 cmLocalVisualStudioGenerator.h 1.7 1.8

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Aug 27 17:05:45 EDT 2007


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

Modified Files:
	cmLocalVisualStudioGenerator.cxx 
	cmLocalVisualStudioGenerator.h 
Log Message:
BUG: fix #5326: source files with the same name in different groups lead to colliding object file names

Alex


Index: cmLocalVisualStudioGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudioGenerator.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cmLocalVisualStudioGenerator.cxx	18 Jun 2007 15:59:23 -0000	1.12
+++ cmLocalVisualStudioGenerator.cxx	27 Aug 2007 21:05:43 -0000	1.13
@@ -51,18 +51,13 @@
 }
 
 //----------------------------------------------------------------------------
-void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
-(std::vector<cmSourceGroup> const& sourceGroups)
+void cmLocalVisualStudioGenerator::CountObjectNames(
+    const std::vector<cmSourceGroup>& groups,
+    std::map<cmStdString, int>& counts)
 {
-  // Clear the current set of requirements.
-  this->NeedObjectName.clear();
-
-  // Count the number of object files with each name.  Note that
-  // windows file names are not case sensitive.
-  std::map<cmStdString, int> objectNameCounts;
-  for(unsigned int i = 0; i < sourceGroups.size(); ++i)
+  for(unsigned int i = 0; i < groups.size(); ++i)
     {
-    cmSourceGroup sg = sourceGroups[i];
+    cmSourceGroup sg = groups[i];
     std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
     for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
         s != srcs.end(); ++s)
@@ -70,21 +65,25 @@
       const cmSourceFile* sf = *s;
       if(this->SourceFileCompiles(sf))
         {
-        std::string objectName =
-          cmSystemTools::LowerCase(
+        std::string objectName = cmSystemTools::LowerCase(
             cmSystemTools::GetFilenameWithoutLastExtension(
               sf->GetFullPath()));
         objectName += ".obj";
-        objectNameCounts[objectName] += 1;
+        counts[objectName] += 1;
         }
       }
+    this->CountObjectNames(sg.GetGroupChildren(), counts);
     }
+}
 
-  // For all source files producing duplicate names we need unique
-  // object name computation.
-  for(unsigned int i = 0; i < sourceGroups.size(); ++i)
+//----------------------------------------------------------------------------
+void cmLocalVisualStudioGenerator::InsertNeedObjectNames(
+   const std::vector<cmSourceGroup>& groups,
+    std::map<cmStdString, int>& count)
+{
+  for(unsigned int i = 0; i < groups.size(); ++i)
     {
-    cmSourceGroup sg = sourceGroups[i];
+    cmSourceGroup sg = groups[i];
     std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
     for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
         s != srcs.end(); ++s)
@@ -92,20 +91,37 @@
       const cmSourceFile* sf = *s;
       if(this->SourceFileCompiles(sf))
         {
-        std::string objectName =
-          cmSystemTools::LowerCase(
-            cmSystemTools::GetFilenameWithoutLastExtension(
-              sf->GetFullPath()));
+        std::string objectName = cmSystemTools::LowerCase(
+           cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
         objectName += ".obj";
-        if(objectNameCounts[objectName] > 1)
+        if(count[objectName] > 1)
           {
           this->NeedObjectName.insert(sf);
           }
         }
       }
+    this->InsertNeedObjectNames(sg.GetGroupChildren(), count);
     }
 }
 
+
+//----------------------------------------------------------------------------
+void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
+(std::vector<cmSourceGroup> const& sourceGroups)
+{
+  // Clear the current set of requirements.
+  this->NeedObjectName.clear();
+
+  // Count the number of object files with each name.  Note that
+  // windows file names are not case sensitive.
+  std::map<cmStdString, int> objectNameCounts;
+  this->CountObjectNames(sourceGroups, objectNameCounts);
+
+  // For all source files producing duplicate names we need unique
+  // object name computation.
+  this->InsertNeedObjectNames(sourceGroups, objectNameCounts);
+}
+
 //----------------------------------------------------------------------------
 std::string
 cmLocalVisualStudioGenerator

Index: cmLocalVisualStudioGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudioGenerator.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cmLocalVisualStudioGenerator.h	9 Jul 2007 18:30:33 -0000	1.7
+++ cmLocalVisualStudioGenerator.h	27 Aug 2007 21:05:43 -0000	1.8
@@ -46,6 +46,11 @@
   // Safe object file name generation.
   void ComputeObjectNameRequirements(std::vector<cmSourceGroup> const&);
   bool SourceFileCompiles(const cmSourceFile* sf);
+  void CountObjectNames(const std::vector<cmSourceGroup>& groups,
+                        std::map<cmStdString, int>& count);
+  void InsertNeedObjectNames(const std::vector<cmSourceGroup>& groups,
+                             std::map<cmStdString, int>& count);
+
   std::set<const cmSourceFile*> NeedObjectName;
 };
 



More information about the Cmake-commits mailing list