[Cmake-commits] CMake branch, next, updated. v2.8.2-949-g6dc009c

Bill Hoffman bill.hoffman at kitware.com
Tue Sep 28 14:38:14 EDT 2010


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  6dc009c46581435241af70ed54ab17c658ceddf4 (commit)
       via  1c2e17f2afe4dfcb2dac543af4a21121722b38f9 (commit)
      from  ca68ba9354e7f9809b7cdc8c7a93898ab157775d (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=6dc009c46581435241af70ed54ab17c658ceddf4
commit 6dc009c46581435241af70ed54ab17c658ceddf4
Merge: ca68ba9 1c2e17f
Author:     Bill Hoffman <bill.hoffman at kitware.com>
AuthorDate: Tue Sep 28 14:38:12 2010 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Sep 28 14:38:12 2010 -0400

    Merge topic 'xcode_source_group_fix_7932' into next
    
    1c2e17f XCode Source Grouping now allows for multiple levels of source groups (7932).


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1c2e17f2afe4dfcb2dac543af4a21121722b38f9
commit 1c2e17f2afe4dfcb2dac543af4a21121722b38f9
Author:     Bill Hoffman <bill.hoffman at kitware.com>
AuthorDate: Mon Sep 27 14:41:47 2010 -0400
Commit:     Bill Hoffman <bill.hoffman at kitware.com>
CommitDate: Tue Sep 28 14:36:56 2010 -0400

    XCode Source Grouping now allows for multiple levels of source groups (7932).
    
    patch given by goatboy160, and updated by Claus Hofele.

diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 4e9969d..3603ddf 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2435,26 +2435,68 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
 
       std::vector<cmSourceFile*>  classes = cmtarget.GetSourceFiles();
 
-      for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); 
+      for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
           s != classes.end(); s++)
         {
         cmSourceFile* sf = *s;
         // Add the file to the list of sources.
         std::string const& source = sf->GetFullPath();
-        cmSourceGroup& sourceGroup = 
+        cmSourceGroup& sourceGroup =
           mf->FindSourceGroup(source.c_str(), sourceGroups);
-        cmXCodeObject* pbxgroup = 
-          this->CreateOrGetPBXGroup(cmtarget, &sourceGroup);
-        cmStdString key = GetGroupMapKey(cmtarget, sf);
-        this->GroupMap[key] = pbxgroup;
+            sourceGroup.AssignSource( sf );
+        }
+
+      // Create all of the groups that should be created for this target.
+      // Loop through every source group.
+      for(unsigned int i = 0; i < sourceGroups.size(); ++i)
+        {
+        this->CreateSourceGroup( sourceGroups[i], cmtarget, false );
+        }
+      }
+    }
+}
+
+//----------------------------------------------------------------------------
+cmXCodeObject* cmGlobalXCodeGenerator
+::CreateSourceGroup( cmSourceGroup& sg, cmTarget& cmtarget, bool child_group )
+{
+  // Only do something with the group if there are files or child groups
+  if( !sg.GetSourceFiles().empty() || !sg.GetGroupChildren().empty() )
+    {
+    cmXCodeObject* pbxgroup =
+      this->CreateOrGetPBXGroup(cmtarget, &sg, !child_group);
+
+    std::vector<const cmSourceFile*>& sources = sg.GetSourceFiles();
+    // Get all the source files and add them to the GroupMap
+    for(std::vector<const cmSourceFile*>::const_iterator s = sources.begin();
+        s != sources.end(); s++)
+      {
+      cmStdString key = GetGroupMapKey(cmtarget, (cmSourceFile*)*s);
+      this->GroupMap[key] = pbxgroup;
+      }
+
+    // Do the child groups
+    std::vector<cmSourceGroup> children  = sg.GetGroupChildren();
+    cmXCodeObject* groupChildren = pbxgroup->GetObject("children");
+
+    for(unsigned int i=0;i<children.size();++i)
+      {
+      cmXCodeObject* group =
+        this->CreateSourceGroup( children[i], cmtarget, true );
+      if (group)
+        {
+        groupChildren->AddObject(group);
         }
       }
-    } 
+    return pbxgroup;
+    }
+  return NULL;
 }
 
+
 //----------------------------------------------------------------------------
 cmXCodeObject* cmGlobalXCodeGenerator
-::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg)
+::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg, bool child_group)
 {
   cmStdString s = cmtarget.GetName();
   s += "/";
@@ -2496,9 +2538,8 @@ cmXCodeObject* cmGlobalXCodeGenerator
     return tgroup;
     }
 
-  cmXCodeObject* tgroupChildren = tgroup->GetObject("children");
   cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
-  cmXCodeObject* groupChildren = 
+  cmXCodeObject* groupChildren =
     this->CreateObject(cmXCodeObject::OBJECT_LIST);
   group->AddAttribute("name", this->CreateString(sg->GetName()));
   group->AddAttribute("children", groupChildren);
@@ -2507,7 +2548,11 @@ cmXCodeObject* cmGlobalXCodeGenerator
     group->AddAttribute("refType", this->CreateString("4"));
     }
   group->AddAttribute("sourceTree", this->CreateString("<group>"));
-  tgroupChildren->AddObject(group);
+  if( child_group )
+    {
+    cmXCodeObject* tgroupChildren = tgroup->GetObject("children");
+    tgroupChildren->AddObject(group);
+    }
   this->GroupNameMap[s] = group;
   return group;
 }
@@ -2608,7 +2653,6 @@ void cmGlobalXCodeGenerator
   productGroup->AddAttribute("children", productGroupChildren);
   this->MainGroupChildren->AddObject(productGroup);
   
-  
   this->RootObject = this->CreateObject(cmXCodeObject::PBXProject);
   this->RootObject->SetComment("Project object");
   group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index b4de805..d4e98e8 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -87,10 +87,13 @@ public:
 
 private: 
   cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
-                                     cmSourceGroup* sg);
+                                     cmSourceGroup* sg,
+                                     bool child_group);
   void CreateGroups(cmLocalGenerator* root,
                     std::vector<cmLocalGenerator*>&
                     generators);
+  cmXCodeObject* CreateSourceGroup( cmSourceGroup& sg,
+                                    cmTarget& cmtarget, bool child_group );
   std::string XCodeEscapePath(const char* p);
   std::string RelativeToSource(const char* p);
   std::string RelativeToBinary(const char* p);

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

Summary of changes:
 Source/cmGlobalXCodeGenerator.cxx |   68 ++++++++++++++++++++++++++++++------
 Source/cmGlobalXCodeGenerator.h   |    5 ++-
 2 files changed, 60 insertions(+), 13 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list