[Cmake-commits] CMake branch, next, updated. v2.8.5-1705-g60b6b19

David Cole david.cole at kitware.com
Wed Aug 24 18:30:33 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  60b6b190cb569a18b6cf415d85ff59fa120a1035 (commit)
       via  1834f232a7f782eadd238a78481e3f9086095e97 (commit)
      from  6c65ae17e1e88d9b16b2229c8ac90986ea55dd1b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=60b6b190cb569a18b6cf415d85ff59fa120a1035
commit 60b6b190cb569a18b6cf415d85ff59fa120a1035
Merge: 6c65ae1 1834f23
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Wed Aug 24 18:30:30 2011 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Aug 24 18:30:30 2011 -0400

    Merge topic 'fix-11690-preserve-xcode-objectids' into next
    
    1834f23 Xcode: Save object id values in CMakeCache.txt (#11690)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1834f232a7f782eadd238a78481e3f9086095e97
commit 1834f232a7f782eadd238a78481e3f9086095e97
Author:     David Cole <david.cole at kitware.com>
AuthorDate: Tue Aug 23 18:22:33 2011 -0400
Commit:     David Cole <david.cole at kitware.com>
CommitDate: Wed Aug 24 18:11:32 2011 -0400

    Xcode: Save object id values in CMakeCache.txt (#11690)
    
    For project and target objects, save their ids in CMakeCache.txt.
    
    Hopefully, that will be enough to allow user settings to be saved
    across multiple CMake generate operations. Other object types may
    also need their ids saved: if so, more code than this commit
    will be necessary...

diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index fd9dacd..cde02b7 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -489,6 +489,7 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects()
     delete this->XCodeObjects[i];
     }
   this->XCodeObjects.clear();
+  this->XCodeObjectIDs.clear();
   this->GroupMap.clear();
   this->GroupNameMap.clear();
   this->TargetGroup.clear();
@@ -496,6 +497,27 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects()
 }
 
 //----------------------------------------------------------------------------
+void cmGlobalXCodeGenerator::addObject(cmXCodeObject *obj)
+{
+  if(obj->GetType() == cmXCodeObject::OBJECT)
+    {
+    cmStdString id = obj->GetId();
+
+    // If this is a duplicate id, it's an error:
+    //
+    if(this->XCodeObjectIDs.count(id))
+      {
+      cmSystemTools::Error(
+        "Xcode generator: duplicate object ids not allowed");
+      }
+
+    this->XCodeObjectIDs.insert(id);
+    }
+
+  this->XCodeObjects.push_back(obj);
+}
+
+//----------------------------------------------------------------------------
 cmXCodeObject*
 cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype)
 {
@@ -508,7 +530,7 @@ cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype)
     {
     obj = new cmXCode21Object(ptype, cmXCodeObject::OBJECT);
     }
-  this->XCodeObjects.push_back(obj);
+  this->addObject(obj);
   return obj;
 }
 
@@ -517,7 +539,7 @@ cmXCodeObject*
 cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type)
 {
   cmXCodeObject* obj = new cmXCodeObject(cmXCodeObject::None, type);
-  this->XCodeObjects.push_back(obj);
+  this->addObject(obj);
   return obj;
 }
 
@@ -2040,6 +2062,9 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
       }
     }
 
+  target->SetId(this->GetOrCreateId(
+    cmtarget.GetName(), target->GetId()).c_str());
+
   return target;
 }
 
@@ -2188,6 +2213,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
     target->AddAttribute("productType", this->CreateString(productType));
     }
   target->SetTarget(&cmtarget);
+  target->SetId(this->GetOrCreateId(
+    cmtarget.GetName(), target->GetId()).c_str());
   return target;
 }
 
@@ -2211,6 +2238,26 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget* t)
 }
 
 //----------------------------------------------------------------------------
+std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name,
+                                                  const char* id)
+{
+  std::string guidStoreName = name;
+  guidStoreName += "_GUID_CMAKE";
+  const char* storedGUID =
+    this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str());
+
+  if(storedGUID)
+    {
+    return storedGUID;
+    }
+
+  this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(),
+    id, "Stored Xcode object GUID", cmCacheManager::INTERNAL);
+
+  return id;
+}
+
+//----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target,
                                              cmXCodeObject* dependTarget)
 {
@@ -2739,6 +2786,12 @@ void cmGlobalXCodeGenerator
 
   this->RootObject = this->CreateObject(cmXCodeObject::PBXProject);
   this->RootObject->SetComment("Project object");
+
+  std::string project_id = "PROJECT_";
+  project_id += root->GetMakefile()->GetProjectName();
+  this->RootObject->SetId(this->GetOrCreateId(
+    project_id.c_str(), this->RootObject->GetId()).c_str());
+
   group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
   this->RootObject->AddAttribute("mainGroup",
                              this->CreateObjectReference(mainGroup));
@@ -3137,6 +3190,11 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root,
     }
   this->WriteXCodePBXProj(fout, root, generators);
   this->ClearXCodeObjects();
+
+  // Since this call may have created new cache entries, save the cache:
+  //
+  root->GetMakefile()->GetCacheManager()->SaveCache(
+    root->GetMakefile()->GetHomeOutputDirectory());
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 39a5fd7..fa55ff0 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -123,6 +123,8 @@ private:
                                 );
   
   cmXCodeObject* FindXCodeTarget(cmTarget*);
+  std::string GetOrCreateId(const char* name, const char* id);
+
   // create cmXCodeObject from these functions so that memory can be managed
   // correctly.  All objects created are stored in this->XCodeObjects.
   cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype);
@@ -197,9 +199,11 @@ protected:
 
   unsigned int XcodeVersion;
   std::string VersionString;
+  std::set<cmStdString> XCodeObjectIDs;
   std::vector<cmXCodeObject*> XCodeObjects;
   cmXCodeObject* RootObject;
 private:
+  void addObject(cmXCodeObject *obj);
   std::string PostBuildMakeTarget(std::string const& tName,
                                   std::string const& configName);
   cmXCodeObject* MainGroupChildren;
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx
index 30e5076..30ade96 100644
--- a/Source/cmXCodeObject.cxx
+++ b/Source/cmXCodeObject.cxx
@@ -12,6 +12,8 @@
 #include "cmXCodeObject.h"
 #include "cmSystemTools.h"
 
+#include <CoreFoundation/CoreFoundation.h> // CFUUIDCreate
+
 //----------------------------------------------------------------------------
 const char* cmXCodeObject::PBXTypeNames[] = {
     "PBXGroup", "PBXBuildStyle", "PBXProject", "PBXHeadersBuildPhase", 
@@ -39,35 +41,35 @@ cmXCodeObject::cmXCodeObject(PBXType ptype, Type type)
   this->PBXTargetDependencyValue = 0;
   this->Target = 0;
   this->Object =0;
-  
+
   this->IsA = ptype;
+
   if(type == OBJECT)
     {
-    cmOStringStream str;
-    str << (void*)this;
-    str << (void*)this;
-    str << (void*)this;
-    this->Id = str.str();
+    // Set the Id of an Xcode object to a unique string for each instance.
+    // However the Xcode user file references certain Ids: for those cases,
+    // override the generated Id using SetId().
+    //
+    char cUuid[40] = {0};
+    CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
+    CFStringRef s = CFUUIDCreateString(kCFAllocatorDefault, uuid);
+    CFStringGetCString(s, cUuid, sizeof(cUuid), kCFStringEncodingUTF8);
+    this->Id = cUuid;
+    CFRelease(s);
+    CFRelease(uuid);
     }
   else
     {
-    this->Id = 
-      "Temporary cmake object, should not be refered to in xcode file";
-    }
-  cmSystemTools::ReplaceString(this->Id, "0x", "");
-  this->Id = cmSystemTools::UpperCase(this->Id);
-  if(this->Id.size() < 24)
-    {
-    int diff = 24 - this->Id.size();
-    for(int i =0; i < diff; ++i)
-      {
-      this->Id += "0";
-      }
+    this->Id =
+      "Temporary cmake object, should not be referred to in Xcode file";
     }
+
+  cmSystemTools::ReplaceString(this->Id, "-", "");
   if(this->Id.size() > 24)
     {
-    this->Id = this->Id.substr(0,24);
+    this->Id = this->Id.substr(0, 24);
     }
+
   this->TypeValue = type;
   if(this->TypeValue == OBJECT)
     {
diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h
index 369fe66..2fb96f3 100644
--- a/Source/cmXCodeObject.h
+++ b/Source/cmXCodeObject.h
@@ -83,6 +83,10 @@ public:
     {
       return this->Id.c_str();
     }
+  void SetId(const char* id)
+    {
+      this->Id = id;
+    }
   cmTarget* GetTarget()
     {
       return this->Target;

-----------------------------------------------------------------------

Summary of changes:
 Source/cmGlobalXCodeGenerator.cxx |   62 +++++++++++++++++++++++++++++++++++-
 Source/cmGlobalXCodeGenerator.h   |    4 ++
 Source/cmXCodeObject.cxx          |   40 ++++++++++++-----------
 Source/cmXCodeObject.h            |    4 ++
 4 files changed, 89 insertions(+), 21 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list