Xcode: Generate 'folder' source type for directories (#14498)
Teach the Xcode generator to set 'lastKnownFileType' to be 'folder' for file references that are directories. If you set 'explicitFileType' to 'sourcecode', then Xcode cannot browse the directory.
This commit is contained in:
parent
bf02e75079
commit
e5ec8ad47d
|
@ -876,10 +876,20 @@ cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
|
||||||
ext = realExt.substr(1);
|
ext = realExt.substr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sourcecode = GetSourcecodeValueFromFileExtension(ext, lang);
|
// If fullpath references a directory, then we need to specify
|
||||||
|
// lastKnownFileType as folder in order for Xcode to be able to open the
|
||||||
fileRef->AddAttribute("explicitFileType",
|
// contents of the folder (Xcode 4.6 does not like explicitFileType=folder).
|
||||||
this->CreateString(sourcecode.c_str()));
|
if(cmSystemTools::FileIsDirectory(fullpath.c_str()))
|
||||||
|
{
|
||||||
|
fileRef->AddAttribute("lastKnownFileType",
|
||||||
|
this->CreateString("folder"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string sourcecode = GetSourcecodeValueFromFileExtension(ext, lang);
|
||||||
|
fileRef->AddAttribute("explicitFileType",
|
||||||
|
this->CreateString(sourcecode.c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
// Store the file path relative to the top of the source tree.
|
// Store the file path relative to the top of the source tree.
|
||||||
std::string path = this->RelativeToSource(fullpath.c_str());
|
std::string path = this->RelativeToSource(fullpath.c_str());
|
||||||
|
@ -1009,7 +1019,8 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
|
||||||
cmTarget::SourceFileFlags tsFlags =
|
cmTarget::SourceFileFlags tsFlags =
|
||||||
cmtarget.GetTargetSourceFileFlags(*i);
|
cmtarget.GetTargetSourceFileFlags(*i);
|
||||||
|
|
||||||
if(strcmp(filetype->GetString(), "compiled.mach-o.objfile") == 0)
|
if(filetype &&
|
||||||
|
strcmp(filetype->GetString(), "compiled.mach-o.objfile") == 0)
|
||||||
{
|
{
|
||||||
externalObjFiles.push_back(xsf);
|
externalObjFiles.push_back(xsf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue