mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 07:11:05 -06:00
Xcode: Properly handle Bundle Resources with more than one hierarchy level
Issue: #16680
This commit is contained in:
@@ -3317,6 +3317,8 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
|
||||
flags.MacFolder = location;
|
||||
if (strcmp(location, "Resources") == 0) {
|
||||
flags.Type = cmGeneratorTarget::SourceFileTypeResource;
|
||||
} else if (cmSystemTools::StringStartsWith(location, "Resources/")) {
|
||||
flags.Type = cmGeneratorTarget::SourceFileTypeDeepResource;
|
||||
} else {
|
||||
flags.Type = cmGeneratorTarget::SourceFileTypeMacContent;
|
||||
}
|
||||
|
||||
@@ -422,7 +422,9 @@ public:
|
||||
SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property
|
||||
SourceFileTypeResource, // is in "RESOURCE" target property *or*
|
||||
// has MACOSX_PACKAGE_LOCATION=="Resources"
|
||||
SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources"
|
||||
SourceFileTypeDeepResource, // MACOSX_PACKAGE_LOCATION starts with
|
||||
// "Resources/"
|
||||
SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources[/]"
|
||||
};
|
||||
struct SourceFileFlags
|
||||
{
|
||||
|
||||
@@ -1177,6 +1177,46 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
|
||||
}
|
||||
}
|
||||
|
||||
// create vector of "resource content file" build phases - only for
|
||||
// framework or bundle targets
|
||||
if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) {
|
||||
typedef std::map<std::string, std::vector<cmSourceFile*> >
|
||||
mapOfVectorOfSourceFiles;
|
||||
mapOfVectorOfSourceFiles bundleFiles;
|
||||
for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
|
||||
i != classes.end(); ++i) {
|
||||
cmGeneratorTarget::SourceFileFlags tsFlags =
|
||||
gtgt->GetTargetSourceFileFlags(*i);
|
||||
if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeDeepResource) {
|
||||
bundleFiles[tsFlags.MacFolder].push_back(*i);
|
||||
}
|
||||
}
|
||||
mapOfVectorOfSourceFiles::iterator mit;
|
||||
for (mit = bundleFiles.begin(); mit != bundleFiles.end(); ++mit) {
|
||||
cmXCodeObject* copyFilesBuildPhase =
|
||||
this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
|
||||
copyFilesBuildPhase->SetComment("Copy files");
|
||||
copyFilesBuildPhase->AddAttribute("buildActionMask",
|
||||
this->CreateString("2147483647"));
|
||||
copyFilesBuildPhase->AddAttribute("dstSubfolderSpec",
|
||||
this->CreateString("7"));
|
||||
const std::string dstPath = mit->first.substr(strlen("Resources/"));
|
||||
copyFilesBuildPhase->AddAttribute("dstPath",
|
||||
this->CreateString(dstPath));
|
||||
copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
|
||||
this->CreateString("0"));
|
||||
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
||||
copyFilesBuildPhase->AddAttribute("files", buildFiles);
|
||||
std::vector<cmSourceFile*>::iterator sfIt;
|
||||
for (sfIt = mit->second.begin(); sfIt != mit->second.end(); ++sfIt) {
|
||||
cmXCodeObject* xsf = this->CreateXCodeSourceFile(
|
||||
this->CurrentLocalGenerator, *sfIt, gtgt);
|
||||
buildFiles->AddObject(xsf);
|
||||
}
|
||||
contentBuildPhases.push_back(copyFilesBuildPhase);
|
||||
}
|
||||
}
|
||||
|
||||
// create framework build phase
|
||||
cmXCodeObject* frameworkBuildPhase = 0;
|
||||
if (!externalObjFiles.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user