Attached Files | 0001-Cmake-Xcode-Support-multiple-level-nesting-of-XCode-.patch [^] (5,020 bytes) 2011-02-15 08:37 [Show Content] [Hide Content]From b857064e0ebd2e39119043a514502e1de7137b2a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Johan=20Bj=C3=B6rk?= <phb@spotify.com>
Date: Tue, 15 Feb 2011 14:34:14 +0100
Subject: [PATCH] Cmake+Xcode: Support multiple level nesting of XCode folders.
---
Source/cmGlobalXCodeGenerator.cxx | 84 +++++++++++++++++++++++++++++++-----
Source/cmGlobalXCodeGenerator.h | 2 +
2 files changed, 74 insertions(+), 12 deletions(-)
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index d5c0fef..38e7780 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2499,6 +2499,54 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
}
}
}
+inline std::vector<std::string> tokenize(const std::string& str,
+ const std::string& sep)
+{
+ std::vector<std::string> tokens;
+ std::string::size_type tokend = 0;
+
+ do
+ {
+ std::string::size_type tokstart=str.find_first_not_of(sep, tokend);
+ if (tokstart==std::string::npos)
+ {
+ break; // no more tokens
+ }
+ tokend=str.find_first_of(sep,tokstart);
+ if (tokend==std::string::npos)
+ {
+ tokens.push_back(str.substr(tokstart));
+ }
+ else
+ {
+ tokens.push_back(str.substr(tokstart,tokend-tokstart));
+ }
+ } while (tokend!=std::string::npos);
+
+ if (tokens.empty())
+ {
+ tokens.push_back("");
+ }
+ return tokens;
+}
+
+cmXCodeObject *cmGlobalXCodeGenerator
+::CreatePBXGroup(cmXCodeObject *parent, cmStdString name)
+{
+ cmXCodeObject* parentChildren = parent->GetObject("children");
+ cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
+ cmXCodeObject* groupChildren =
+ this->CreateObject(cmXCodeObject::OBJECT_LIST);
+ group->AddAttribute("name", this->CreateString(name.c_str()));
+ group->AddAttribute("children", groupChildren);
+ if(this->XcodeVersion == 15)
+ {
+ group->AddAttribute("refType", this->CreateString("4"));
+ }
+ group->AddAttribute("sourceTree", this->CreateString("<group>"));
+ parentChildren->AddObject(group);
+ return group;
+}
//----------------------------------------------------------------------------
cmXCodeObject* cmGlobalXCodeGenerator
@@ -2506,7 +2554,7 @@ cmXCodeObject* cmGlobalXCodeGenerator
{
cmStdString s = cmtarget.GetName();
s += "/";
- s += sg->GetName();
+ s += sg->GetFullName();
std::map<cmStdString, cmXCodeObject* >::iterator i =
this->GroupNameMap.find(s);
if(i != this->GroupNameMap.end())
@@ -2538,24 +2586,36 @@ cmXCodeObject* cmGlobalXCodeGenerator
// If it's the default source group (empty name) then put the source file
// directly in the tgroup...
//
- if (cmStdString(sg->GetName()) == "")
+ if (cmStdString(sg->GetFullName()) == "")
{
this->GroupNameMap[s] = tgroup;
return tgroup;
}
- cmXCodeObject* tgroupChildren = tgroup->GetObject("children");
- cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
- cmXCodeObject* groupChildren =
- this->CreateObject(cmXCodeObject::OBJECT_LIST);
- group->AddAttribute("name", this->CreateString(sg->GetName()));
- group->AddAttribute("children", groupChildren);
- if(this->XcodeVersion == 15)
+ //It's a recursive folder structure, let's find the real parent group
+ if(std::string(sg->GetFullName()) != std::string(sg->GetName()))
{
- group->AddAttribute("refType", this->CreateString("4"));
+ std::vector<std::string> folders = tokenize(sg->GetFullName(), "\\");
+ cmStdString curr_folder = cmtarget.GetName();
+ curr_folder += "/";
+ for(int i = 0; i < folders.size();i++)
+ {
+ curr_folder += folders[i];
+ std::map<cmStdString, cmXCodeObject* >::iterator i_folder = this->GroupNameMap.find(curr_folder);
+ //Create new folder
+ if(i_folder == this->GroupNameMap.end())
+ {
+ cmXCodeObject *group = this->CreatePBXGroup(tgroup,folders[i]);
+ this->GroupNameMap[curr_folder] = group;
+ tgroup = group;
+ } else {
+ tgroup = i_folder->second;
+ }
+ curr_folder = curr_folder + "\\";
}
- group->AddAttribute("sourceTree", this->CreateString("<group>"));
- tgroupChildren->AddObject(group);
+ return tgroup;
+ }
+ cmXCodeObject *group = this->CreatePBXGroup(tgroup,sg->GetName());
this->GroupNameMap[s] = group;
return group;
}
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 290532a..22a78f2 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -88,6 +88,8 @@ public:
private:
cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
cmSourceGroup* sg);
+ cmXCodeObject* CreatePBXGroup(cmXCodeObject *parent,
+ cmStdString name);
void CreateGroups(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>&
generators);
--
1.7.2.1
2-Cmake-Xcode-Support-multiple-level-nesting-of-XCode-.patch [^] (7,722 bytes) 2011-02-15 09:33 [Show Content] [Hide Content]From 439f934f898ba858d479cae02c3465cb311200ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Johan=20Bj=C3=B6rk?= <phb@spotify.com>
Date: Tue, 15 Feb 2011 14:34:14 +0100
Subject: [PATCH 1/2] Cmake+Xcode: Support multiple level nesting of XCode folders.
Cmake: Move tokenize to cmSystemTools.cxx
---
Source/cmGlobalXCodeGenerator.cxx | 54 ++++++++++++++++++++++++++++--------
Source/cmGlobalXCodeGenerator.h | 2 +
Source/cmSourceGroupCommand.cxx | 33 +----------------------
Source/cmSystemTools.cxx | 32 ++++++++++++++++++++++
Source/cmSystemTools.h | 3 ++
5 files changed, 80 insertions(+), 44 deletions(-)
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index d5c0fef..9b97dbf 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2500,13 +2500,31 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
}
}
+cmXCodeObject *cmGlobalXCodeGenerator
+::CreatePBXGroup(cmXCodeObject *parent, cmStdString name)
+{
+ cmXCodeObject* parentChildren = parent->GetObject("children");
+ cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
+ cmXCodeObject* groupChildren =
+ this->CreateObject(cmXCodeObject::OBJECT_LIST);
+ group->AddAttribute("name", this->CreateString(name.c_str()));
+ group->AddAttribute("children", groupChildren);
+ if(this->XcodeVersion == 15)
+ {
+ group->AddAttribute("refType", this->CreateString("4"));
+ }
+ group->AddAttribute("sourceTree", this->CreateString("<group>"));
+ parentChildren->AddObject(group);
+ return group;
+}
+
//----------------------------------------------------------------------------
cmXCodeObject* cmGlobalXCodeGenerator
::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg)
{
cmStdString s = cmtarget.GetName();
s += "/";
- s += sg->GetName();
+ s += sg->GetFullName();
std::map<cmStdString, cmXCodeObject* >::iterator i =
this->GroupNameMap.find(s);
if(i != this->GroupNameMap.end())
@@ -2538,24 +2556,36 @@ cmXCodeObject* cmGlobalXCodeGenerator
// If it's the default source group (empty name) then put the source file
// directly in the tgroup...
//
- if (cmStdString(sg->GetName()) == "")
+ if (cmStdString(sg->GetFullName()) == "")
{
this->GroupNameMap[s] = tgroup;
return tgroup;
}
- cmXCodeObject* tgroupChildren = tgroup->GetObject("children");
- cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
- cmXCodeObject* groupChildren =
- this->CreateObject(cmXCodeObject::OBJECT_LIST);
- group->AddAttribute("name", this->CreateString(sg->GetName()));
- group->AddAttribute("children", groupChildren);
- if(this->XcodeVersion == 15)
+ //It's a recursive folder structure, let's find the real parent group
+ if(std::string(sg->GetFullName()) != std::string(sg->GetName()))
{
- group->AddAttribute("refType", this->CreateString("4"));
+ std::vector<std::string> folders = cmSystemTools::tokenize(sg->GetFullName(), "\\");
+ cmStdString curr_folder = cmtarget.GetName();
+ curr_folder += "/";
+ for(int i = 0; i < folders.size();i++)
+ {
+ curr_folder += folders[i];
+ std::map<cmStdString, cmXCodeObject* >::iterator i_folder = this->GroupNameMap.find(curr_folder);
+ //Create new folder
+ if(i_folder == this->GroupNameMap.end())
+ {
+ cmXCodeObject *group = this->CreatePBXGroup(tgroup,folders[i]);
+ this->GroupNameMap[curr_folder] = group;
+ tgroup = group;
+ } else {
+ tgroup = i_folder->second;
+ }
+ curr_folder = curr_folder + "\\";
}
- group->AddAttribute("sourceTree", this->CreateString("<group>"));
- tgroupChildren->AddObject(group);
+ return tgroup;
+ }
+ cmXCodeObject *group = this->CreatePBXGroup(tgroup,sg->GetName());
this->GroupNameMap[s] = group;
return group;
}
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 290532a..22a78f2 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -88,6 +88,8 @@ public:
private:
cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
cmSourceGroup* sg);
+ cmXCodeObject* CreatePBXGroup(cmXCodeObject *parent,
+ cmStdString name);
void CreateGroups(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>&
generators);
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index 27d90db..22f4d47 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -11,37 +11,6 @@
============================================================================*/
#include "cmSourceGroupCommand.h"
-inline std::vector<std::string> tokenize(const std::string& str,
- const std::string& sep)
-{
- std::vector<std::string> tokens;
- std::string::size_type tokend = 0;
-
- do
- {
- std::string::size_type tokstart=str.find_first_not_of(sep, tokend);
- if (tokstart==std::string::npos)
- {
- break; // no more tokens
- }
- tokend=str.find_first_of(sep,tokstart);
- if (tokend==std::string::npos)
- {
- tokens.push_back(str.substr(tokstart));
- }
- else
- {
- tokens.push_back(str.substr(tokstart,tokend-tokstart));
- }
- } while (tokend!=std::string::npos);
-
- if (tokens.empty())
- {
- tokens.push_back("");
- }
- return tokens;
-}
-
// cmSourceGroupCommand
bool cmSourceGroupCommand
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
@@ -58,7 +27,7 @@ bool cmSourceGroupCommand
delimiter = this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER");
}
- std::vector<std::string> folders = tokenize(args[0], delimiter);
+ std::vector<std::string> folders = cmSystemTools::tokenize(args[0], delimiter);
cmSourceGroup* sg = 0;
sg = this->Makefile->GetSourceGroup(folders);
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 7bc89a4..069ff17 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2833,3 +2833,35 @@ bool cmSystemTools::RepeatedRemoveDirectory(const char* dir)
}
return false;
}
+
+//----------------------------------------------------------------------------
+std::vector<std::string> cmSystemTools::tokenize(const std::string& str,
+ const std::string& sep)
+{
+ std::vector<std::string> tokens;
+ std::string::size_type tokend = 0;
+
+ do
+ {
+ std::string::size_type tokstart=str.find_first_not_of(sep, tokend);
+ if (tokstart==std::string::npos)
+ {
+ break; // no more tokens
+ }
+ tokend=str.find_first_of(sep,tokstart);
+ if (tokend==std::string::npos)
+ {
+ tokens.push_back(str.substr(tokstart));
+ }
+ else
+ {
+ tokens.push_back(str.substr(tokstart,tokend-tokstart));
+ }
+ } while (tokend!=std::string::npos);
+
+ if (tokens.empty())
+ {
+ tokens.push_back("");
+ }
+ return tokens;
+}
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 6f9147c..5b5c768 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -439,6 +439,9 @@ public:
/** Remove a directory; repeat a few times in case of locked files. */
static bool RepeatedRemoveDirectory(const char* dir);
+ /** Tokenize a string */
+ static std::vector<std::string> tokenize(const std::string& str,
+ const std::string& sep);
private:
static bool s_ForceUnixPaths;
static bool s_RunCommandHideConsole;
--
1.7.2.1
3-code-Support-multiple-level-nesting-of-XCode-.patch [^] (8,446 bytes) 2011-02-15 13:34 [Show Content] [Hide Content]From c2ed38690eaba8f4f0e90a07f58dcdda71b7f96e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Johan=20Bj=C3=B6rk?= <phb@spotify.com>
Date: Tue, 15 Feb 2011 14:34:14 +0100
Subject: [PATCH 1/2] Cmake+Xcode: Support multiple level nesting of XCode folders.
Cmake: Move tokenize to cmSystemTools.cxx
---
Source/cmGlobalXCodeGenerator.cxx | 68 +++++++++++++++++++++++++------------
Source/cmGlobalXCodeGenerator.h | 2 +
Source/cmSourceGroupCommand.cxx | 33 +-----------------
Source/cmSystemTools.cxx | 32 +++++++++++++++++
Source/cmSystemTools.h | 3 ++
5 files changed, 84 insertions(+), 54 deletions(-)
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index d5c0fef..c336e08 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2500,13 +2500,34 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
}
}
+cmXCodeObject *cmGlobalXCodeGenerator
+::CreatePBXGroup(cmXCodeObject *parent, cmStdString name)
+{
+ cmXCodeObject* parentChildren = NULL;
+ if(parent)
+ parentChildren = parent->GetObject("children");
+ cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
+ cmXCodeObject* groupChildren =
+ this->CreateObject(cmXCodeObject::OBJECT_LIST);
+ group->AddAttribute("name", this->CreateString(name.c_str()));
+ group->AddAttribute("children", groupChildren);
+ if(this->XcodeVersion == 15)
+ {
+ group->AddAttribute("refType", this->CreateString("4"));
+ }
+ group->AddAttribute("sourceTree", this->CreateString("<group>"));
+ if(parentChildren)
+ parentChildren->AddObject(group);
+ return group;
+}
+
//----------------------------------------------------------------------------
cmXCodeObject* cmGlobalXCodeGenerator
::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg)
{
cmStdString s = cmtarget.GetName();
s += "/";
- s += sg->GetName();
+ s += sg->GetFullName();
std::map<cmStdString, cmXCodeObject* >::iterator i =
this->GroupNameMap.find(s);
if(i != this->GroupNameMap.end())
@@ -2521,41 +2542,44 @@ cmXCodeObject* cmGlobalXCodeGenerator
}
else
{
- tgroup = this->CreateObject(cmXCodeObject::PBXGroup);
+ tgroup = this->CreatePBXGroup(NULL,cmtarget.GetName());
this->TargetGroup[cmtarget.GetName()] = tgroup;
- cmXCodeObject* tgroupChildren =
- this->CreateObject(cmXCodeObject::OBJECT_LIST);
- tgroup->AddAttribute("name", this->CreateString(cmtarget.GetName()));
- tgroup->AddAttribute("children", tgroupChildren);
- if(this->XcodeVersion == 15)
- {
- tgroup->AddAttribute("refType", this->CreateString("4"));
- }
- tgroup->AddAttribute("sourceTree", this->CreateString("<group>"));
this->SourcesGroupChildren->AddObject(tgroup);
}
// If it's the default source group (empty name) then put the source file
// directly in the tgroup...
//
- if (cmStdString(sg->GetName()) == "")
+ if (cmStdString(sg->GetFullName()) == "")
{
this->GroupNameMap[s] = tgroup;
return tgroup;
}
- cmXCodeObject* tgroupChildren = tgroup->GetObject("children");
- cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
- cmXCodeObject* groupChildren =
- this->CreateObject(cmXCodeObject::OBJECT_LIST);
- group->AddAttribute("name", this->CreateString(sg->GetName()));
- group->AddAttribute("children", groupChildren);
- if(this->XcodeVersion == 15)
+ //It's a recursive folder structure, let's find the real parent group
+ if(std::string(sg->GetFullName()) != std::string(sg->GetName()))
{
- group->AddAttribute("refType", this->CreateString("4"));
+ std::vector<std::string> folders = cmSystemTools::tokenize(sg->GetFullName(), "\\");
+ cmStdString curr_folder = cmtarget.GetName();
+ curr_folder += "/";
+ for(int i = 0; i < folders.size();i++)
+ {
+ curr_folder += folders[i];
+ std::map<cmStdString, cmXCodeObject* >::iterator i_folder = this->GroupNameMap.find(curr_folder);
+ //Create new folder
+ if(i_folder == this->GroupNameMap.end())
+ {
+ cmXCodeObject *group = this->CreatePBXGroup(tgroup,folders[i]);
+ this->GroupNameMap[curr_folder] = group;
+ tgroup = group;
+ } else {
+ tgroup = i_folder->second;
+ }
+ curr_folder = curr_folder + "\\";
}
- group->AddAttribute("sourceTree", this->CreateString("<group>"));
- tgroupChildren->AddObject(group);
+ return tgroup;
+ }
+ cmXCodeObject *group = this->CreatePBXGroup(tgroup,sg->GetName());
this->GroupNameMap[s] = group;
return group;
}
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 290532a..22a78f2 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -88,6 +88,8 @@ public:
private:
cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
cmSourceGroup* sg);
+ cmXCodeObject* CreatePBXGroup(cmXCodeObject *parent,
+ cmStdString name);
void CreateGroups(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>&
generators);
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index 27d90db..22f4d47 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -11,37 +11,6 @@
============================================================================*/
#include "cmSourceGroupCommand.h"
-inline std::vector<std::string> tokenize(const std::string& str,
- const std::string& sep)
-{
- std::vector<std::string> tokens;
- std::string::size_type tokend = 0;
-
- do
- {
- std::string::size_type tokstart=str.find_first_not_of(sep, tokend);
- if (tokstart==std::string::npos)
- {
- break; // no more tokens
- }
- tokend=str.find_first_of(sep,tokstart);
- if (tokend==std::string::npos)
- {
- tokens.push_back(str.substr(tokstart));
- }
- else
- {
- tokens.push_back(str.substr(tokstart,tokend-tokstart));
- }
- } while (tokend!=std::string::npos);
-
- if (tokens.empty())
- {
- tokens.push_back("");
- }
- return tokens;
-}
-
// cmSourceGroupCommand
bool cmSourceGroupCommand
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
@@ -58,7 +27,7 @@ bool cmSourceGroupCommand
delimiter = this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER");
}
- std::vector<std::string> folders = tokenize(args[0], delimiter);
+ std::vector<std::string> folders = cmSystemTools::tokenize(args[0], delimiter);
cmSourceGroup* sg = 0;
sg = this->Makefile->GetSourceGroup(folders);
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 7bc89a4..069ff17 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2833,3 +2833,35 @@ bool cmSystemTools::RepeatedRemoveDirectory(const char* dir)
}
return false;
}
+
+//----------------------------------------------------------------------------
+std::vector<std::string> cmSystemTools::tokenize(const std::string& str,
+ const std::string& sep)
+{
+ std::vector<std::string> tokens;
+ std::string::size_type tokend = 0;
+
+ do
+ {
+ std::string::size_type tokstart=str.find_first_not_of(sep, tokend);
+ if (tokstart==std::string::npos)
+ {
+ break; // no more tokens
+ }
+ tokend=str.find_first_of(sep,tokstart);
+ if (tokend==std::string::npos)
+ {
+ tokens.push_back(str.substr(tokstart));
+ }
+ else
+ {
+ tokens.push_back(str.substr(tokstart,tokend-tokstart));
+ }
+ } while (tokend!=std::string::npos);
+
+ if (tokens.empty())
+ {
+ tokens.push_back("");
+ }
+ return tokens;
+}
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 6f9147c..5b5c768 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -439,6 +439,9 @@ public:
/** Remove a directory; repeat a few times in case of locked files. */
static bool RepeatedRemoveDirectory(const char* dir);
+ /** Tokenize a string */
+ static std::vector<std::string> tokenize(const std::string& str,
+ const std::string& sep);
private:
static bool s_ForceUnixPaths;
static bool s_RunCommandHideConsole;
--
1.7.2.1
0002-XCode-Support-target-folders-on-XCode.patch [^] (2,579 bytes) 2011-02-20 09:12 [Show Content] [Hide Content]From e5f8b41da5e3c80f5c0a5d79d6d0e8f07f34502f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Johan=20Bj=C3=B6rk?= <phb@spotify.com>
Date: Sun, 20 Feb 2011 14:05:41 +0100
Subject: [PATCH 2/3] XCode: Support target folders on XCode.
---
Source/cmGlobalXCodeGenerator.cxx | 51 ++++++++++++++++++++++++++++--------
1 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index c85882f..2a1e7d3 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2556,27 +2556,54 @@ cmXCodeObject *cmGlobalXCodeGenerator
cmXCodeObject* cmGlobalXCodeGenerator
::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg)
{
- cmStdString s = cmtarget.GetName();
- s += "/";
+ cmStdString s;
+ cmStdString target;
+ const char *targetFolder= cmtarget.GetProperty("FOLDER");
+ if(targetFolder) {
+ target = targetFolder;
+ target += "/";
+ }
+ target += cmtarget.GetName();
+ s = target + "/";
s += sg->GetFullName();
- std::map<cmStdString, cmXCodeObject* >::iterator i =
+ std::map<cmStdString, cmXCodeObject* >::iterator it =
this->GroupNameMap.find(s);
- if(i != this->GroupNameMap.end())
+ if(it != this->GroupNameMap.end())
{
- return i->second;
+ return it->second;
}
- i = this->TargetGroup.find(cmtarget.GetName());
+
+ it = this->TargetGroup.find(target);
cmXCodeObject* tgroup = 0;
- if(i != this->TargetGroup.end())
+ if(it != this->TargetGroup.end())
{
- tgroup = i->second;
+ tgroup = it->second;
}
else
{
- tgroup = this->CreatePBXGroup(NULL,cmtarget.GetName());
- this->TargetGroup[cmtarget.GetName()] = tgroup;
- this->SourcesGroupChildren->AddObject(tgroup);
- }
+ std::vector<std::string> tgt_folders = cmSystemTools::tokenize(target, "/");
+ cmStdString curr_tgt_folder;
+ for(int i = 0; i < tgt_folders.size();i++)
+ {
+ curr_tgt_folder += tgt_folders[i];
+ it = this->TargetGroup.find(curr_tgt_folder);
+ if(it == this->TargetGroup.end())
+ {
+ tgroup = this->CreatePBXGroup(tgroup,tgt_folders[i]);
+ this->TargetGroup[curr_tgt_folder] = tgroup;
+ }
+ else
+ {
+ tgroup = it->second;
+ continue;
+ }
+ if(i == 0)
+ this->SourcesGroupChildren->AddObject(tgroup);
+
+ curr_tgt_folder += "/";
+ }
+ }
+ this->TargetGroup[target] = tgroup;
// If it's the default source group (empty name) then put the source file
// directly in the tgroup...
--
1.7.2.1
|