Browse Source

Xcode: Sort source files

Since Xcode doesn't sort the files on its own, let's sort them in our
generator to make navigation easier.  Visual Studio, QtCreator, and
kdevelop all display files sorted.
Alexander Chehovsky 13 năm trước cách đây
mục cha
commit
f6a8983db4
1 tập tin đã thay đổi với 12 bổ sung1 xóa
  1. 12 1
      Source/cmGlobalXCodeGenerator.cxx

+ 12 - 1
Source/cmGlobalXCodeGenerator.cxx

@@ -955,6 +955,15 @@ void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen)
     }
 }
 
+//----------------------------------------------------------------------------
+struct cmSourceFilePathCompare
+{
+  bool operator()(cmSourceFile* l, cmSourceFile* r)
+  {
+    return l->GetFullPath() < r->GetFullPath();
+  }
+};
+
 //----------------------------------------------------------------------------
 void
 cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
@@ -981,7 +990,9 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
       }
 
     // organize the sources
-    std::vector<cmSourceFile*> const &classes = cmtarget.GetSourceFiles();
+    std::vector<cmSourceFile*> classes = cmtarget.GetSourceFiles();
+    std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare());
+
     std::vector<cmXCodeObject*> externalObjFiles;
     std::vector<cmXCodeObject*> headerFiles;
     std::vector<cmXCodeObject*> resourceFiles;