summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorJohan Björk <phb@spotify.com>2011-02-15 13:34:14 (GMT)
committerBrad King <brad.king@kitware.com>2011-06-07 14:21:49 (GMT)
commit59ed84e032922f4d44b973837aa24497d182d2d3 (patch)
treeda24c45fed5432cc6a1376d1c394ea72c404b2ef /Source/cmGlobalXCodeGenerator.cxx
parentd0a403fd99e000f32467f66fe898d785f30435eb (diff)
downloadCMake-59ed84e032922f4d44b973837aa24497d182d2d3.zip
CMake-59ed84e032922f4d44b973837aa24497d182d2d3.tar.gz
CMake-59ed84e032922f4d44b973837aa24497d182d2d3.tar.bz2
Xcode: Support multiple level nesting of XCode folders (#10039)
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx70
1 files changed, 48 insertions, 22 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 358721f..e7ae8be 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2456,13 +2456,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())
@@ -2477,41 +2498,46 @@ 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(std::vector<std::string>::size_type 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 + "\\";
+ }
+ return tgroup;
}
- group->AddAttribute("sourceTree", this->CreateString("<group>"));
- tgroupChildren->AddObject(group);
+ cmXCodeObject *group = this->CreatePBXGroup(tgroup,sg->GetName());
this->GroupNameMap[s] = group;
return group;
}