XCode: Support target folders on XCode.

This commit is contained in:
Johan Björk 2011-02-20 14:05:41 +01:00 committed by Brad King
parent 59ed84e032
commit eeeeca1082
1 changed files with 39 additions and 11 deletions

View File

@ -2481,27 +2481,55 @@ cmXCodeObject *cmGlobalXCodeGenerator
cmXCodeObject* cmGlobalXCodeGenerator cmXCodeObject* cmGlobalXCodeGenerator
::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg) ::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg)
{ {
cmStdString s = cmtarget.GetName(); cmStdString s;
s += "/"; cmStdString target;
s += sg->GetFullName(); const char *targetFolder= cmtarget.GetProperty("FOLDER");
std::map<cmStdString, cmXCodeObject* >::iterator i = if(targetFolder) {
this->GroupNameMap.find(s); target = targetFolder;
if(i != this->GroupNameMap.end()) target += "/";
{
return i->second;
} }
i = this->TargetGroup.find(cmtarget.GetName()); target += cmtarget.GetName();
cmXCodeObject* tgroup = 0; s = target + "/";
if(i != this->TargetGroup.end()) s += sg->GetFullName();
std::map<cmStdString, cmXCodeObject* >::iterator it =
this->GroupNameMap.find(s);
if(it != this->GroupNameMap.end())
{ {
tgroup = i->second; return it->second;
}
it = this->TargetGroup.find(target);
cmXCodeObject* tgroup = 0;
if(it != this->TargetGroup.end())
{
tgroup = it->second;
} }
else else
{ {
tgroup = this->CreatePBXGroup(NULL,cmtarget.GetName()); std::vector<std::string> tgt_folders = cmSystemTools::tokenize(target, "/");
this->TargetGroup[cmtarget.GetName()] = tgroup; cmStdString curr_tgt_folder;
for(std::vector<std::string>::size_type 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); 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 // If it's the default source group (empty name) then put the source file
// directly in the tgroup... // directly in the tgroup...