Xcode keeps the objects ordered by the object id.
Because cmake stores them into an unordered container
at creation time they must be sorted before writing the
pbxproj file.
---
 Source/cmGlobalXCodeGenerator.cxx | 16 ++++++++++++++++
 Source/cmGlobalXCodeGenerator.h   |  1 +
 2 files changed, 17 insertions(+)

diff --git a/Source/cmGlobalXCodeGenerator.cxx 
b/Source/cmGlobalXCodeGenerator.cxx
index 0561a05..be40c66 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -592,6 +592,20 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
 }
 
 //----------------------------------------------------------------------------
+
+static bool objectIdLessThan(cmXCodeObject* l, cmXCodeObject* r)
+{
+  return l->GetId() < r->GetId();
+}
+
+//----------------------------------------------------------------------------
+void cmGlobalXCodeGenerator::SortXCodeObjects()
+{
+  std::sort(this->XCodeObjects.begin(), this->XCodeObjects.end(),
+            objectIdLessThan);
+}
+
+//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::ClearXCodeObjects()
 {
   this->TargetDoneSet.clear();
@@ -3713,6 +3727,8 @@ cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& 
fout,
                                           cmLocalGenerator* ,
                                           std::vector<cmLocalGenerator*>& )
 {
+  SortXCodeObjects();
+
   fout << "// !$*UTF8*$!\n";
   fout << "{\n";
   cmXCodeObject::Indent(1, fout);
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index b272f6a..1a69fce 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -150,6 +150,7 @@ private:
                            cmXCodeObject* buildSettings,
                            const std::string& buildType);
   std::string ExtractFlag(const char* flag, std::string& flags);
+  void SortXCodeObjects();
   // delete all objects in the this->XCodeObjects vector.
   void ClearXCodeObjects();
   bool CreateXCodeObjects(cmLocalGenerator* root,
-- 
2.3.3

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to