diff options
author | Gregor Jasny <gjasny@googlemail.com> | 2017-02-26 21:12:44 (GMT) |
---|---|---|
committer | Gregor Jasny <gjasny@googlemail.com> | 2017-03-22 22:36:11 (GMT) |
commit | 060be58c6f9ffe11235341bc10c8f5d808e31b3d (patch) | |
tree | 499131398261812a2f530e63567bed3d1e2db283 /Source | |
parent | 484ccb0c454afa36da6b36e4ca5e0258e1739b3d (diff) | |
download | CMake-060be58c6f9ffe11235341bc10c8f5d808e31b3d.zip CMake-060be58c6f9ffe11235341bc10c8f5d808e31b3d.tar.gz CMake-060be58c6f9ffe11235341bc10c8f5d808e31b3d.tar.bz2 |
Xcode: Properly handle Bundle Resources with more than one hierarchy level
Issue: #16680
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 2 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 4 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 40 |
3 files changed, 45 insertions, 1 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e27424f..64b05c3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -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; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 68d6ef8..d60ad24 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -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 { diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 3f5dde7..bd0f55b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -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()) { |