summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst7
-rw-r--r--Source/cmGeneratorTarget.cxx12
-rw-r--r--Source/cmGeneratorTarget.h4
-rw-r--r--Source/cmGlobalGenerator.cxx5
-rw-r--r--Source/cmGlobalGenerator.h4
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx53
-rw-r--r--Source/cmGlobalXCodeGenerator.h2
-rw-r--r--Tests/RunCMake/Framework/FrameworkLayout.cmake8
-rw-r--r--Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake15
-rw-r--r--Tests/RunCMake/Framework/deepresource.txt0
-rw-r--r--Tests/RunCMake/Framework/flatresource.txt0
-rw-r--r--Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake15
-rw-r--r--Tests/RunCMake/Framework/some.txt0
13 files changed, 120 insertions, 5 deletions
diff --git a/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst b/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst
index 69cdcb7..a064afa 100644
--- a/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst
+++ b/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst
@@ -21,3 +21,10 @@ extension is changed). See the :prop_tgt:`PUBLIC_HEADER`,
:prop_tgt:`PRIVATE_HEADER`, and :prop_tgt:`RESOURCE` target properties for
specifying files meant for ``Headers``, ``PrivateHeaders``, or
``Resources`` directories.
+
+If the specified location is equal to ``Resources``, the resulting location
+will be the same as if the :prop_tgt:`RESOURCE` property had been used. If
+the specified location is a sub-folder of ``Resources``, it will be placed
+into the respective sub-folder. Note: For iOS Apple uses a flat bundle layout
+where no ``Resources`` folder exist. Therefore CMake strips the ``Resources``
+folder name from the specified location.
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index e27424f..f78a933 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -3315,8 +3315,18 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
// were not listed in one of the other lists.
if (const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) {
flags.MacFolder = location;
+ const bool stripResources =
+ this->GlobalGenerator->ShouldStripResourcePath(this->Makefile);
if (strcmp(location, "Resources") == 0) {
flags.Type = cmGeneratorTarget::SourceFileTypeResource;
+ if (stripResources) {
+ flags.MacFolder = "";
+ }
+ } else if (cmSystemTools::StringStartsWith(location, "Resources/")) {
+ flags.Type = cmGeneratorTarget::SourceFileTypeDeepResource;
+ if (stripResources) {
+ flags.MacFolder += strlen("Resources/");
+ }
} else {
flags.Type = cmGeneratorTarget::SourceFileTypeMacContent;
}
@@ -3370,7 +3380,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
if (cmSourceFile* sf = this->Makefile->GetSource(*it)) {
SourceFileFlags& flags = this->SourceFlagsMap[sf];
flags.MacFolder = "";
- if (!this->Makefile->PlatformIsAppleIos()) {
+ if (!this->GlobalGenerator->ShouldStripResourcePath(this->Makefile)) {
flags.MacFolder = "Resources";
}
flags.Type = cmGeneratorTarget::SourceFileTypeResource;
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/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 0d53bf7..851290a 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2487,6 +2487,11 @@ std::string cmGlobalGenerator::GenerateRuleFile(
return ruleFile;
}
+bool cmGlobalGenerator::ShouldStripResourcePath(cmMakefile* mf) const
+{
+ return mf->PlatformIsAppleIos();
+}
+
std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage(
std::string const& l) const
{
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index b3cb41f..2558fee 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -337,6 +337,10 @@ public:
relevant for mixed macOS and iOS builds. */
virtual bool UseEffectivePlatformName(cmMakefile*) const { return false; }
+ /** Return whether the "Resources" folder prefix should be stripped from
+ MacFolder. */
+ virtual bool ShouldStripResourcePath(cmMakefile*) const;
+
std::string GetSharedLibFlagsForLanguage(std::string const& lang) const;
/** Generate an <output>.rule file path for a given command output. */
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 77f3408..39f7b8f 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1154,8 +1154,12 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
// dstPath in frameworks is relative to Versions/<version>
ostr << mit->first;
} else if (mit->first != "MacOS") {
- // dstPath in bundles is relative to Contents/MacOS
- ostr << "../" << mit->first.c_str();
+ if (gtgt->Target->GetMakefile()->PlatformIsAppleIos()) {
+ ostr << mit->first;
+ } else {
+ // dstPath in bundles is relative to Contents/MacOS
+ ostr << "../" << mit->first;
+ }
}
copyFilesBuildPhase->AddAttribute("dstPath",
this->CreateString(ostr.str()));
@@ -1173,6 +1177,45 @@ 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"));
+ copyFilesBuildPhase->AddAttribute("dstPath",
+ this->CreateString(mit->first));
+ 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()) {
@@ -3657,6 +3700,12 @@ bool cmGlobalXCodeGenerator::UseEffectivePlatformName(cmMakefile* mf) const
return cmSystemTools::IsOn(epnValue);
}
+bool cmGlobalXCodeGenerator::ShouldStripResourcePath(cmMakefile*) const
+{
+ // Xcode determines Resource location itself
+ return true;
+}
+
void cmGlobalXCodeGenerator::ComputeTargetObjectDirectory(
cmGeneratorTarget* gt) const
{
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 9eacdef..172e414 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -88,6 +88,8 @@ public:
bool UseEffectivePlatformName(cmMakefile* mf) const CM_OVERRIDE;
+ bool ShouldStripResourcePath(cmMakefile*) const CM_OVERRIDE;
+
bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf) CM_OVERRIDE;
void AppendFlag(std::string& flags, std::string const& flag);
diff --git a/Tests/RunCMake/Framework/FrameworkLayout.cmake b/Tests/RunCMake/Framework/FrameworkLayout.cmake
index ae32134..dcfbd2d 100644
--- a/Tests/RunCMake/Framework/FrameworkLayout.cmake
+++ b/Tests/RunCMake/Framework/FrameworkLayout.cmake
@@ -4,11 +4,17 @@ enable_language(C)
add_library(Framework ${FRAMEWORK_TYPE}
foo.c
foo.h
- res.txt)
+ res.txt
+ flatresource.txt
+ deepresource.txt
+ some.txt)
set_target_properties(Framework PROPERTIES
FRAMEWORK TRUE
PUBLIC_HEADER foo.h
RESOURCE "res.txt")
+set_source_files_properties(flatresource.txt PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
+set_source_files_properties(deepresource.txt PROPERTIES MACOSX_PACKAGE_LOCATION Resources/deep)
+set_source_files_properties(some.txt PROPERTIES MACOSX_PACKAGE_LOCATION somedir)
add_custom_command(TARGET Framework POST_BUILD
COMMAND /usr/bin/file $<TARGET_FILE:Framework>)
diff --git a/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake b/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake
index da1ccb4..1a543d8 100644
--- a/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake
+++ b/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake
@@ -1,8 +1,11 @@
set(framework-dir "${RunCMake_TEST_BINARY_DIR}/Framework.framework")
set(framework-resources "${framework-dir}/Resources")
set(framework-resource-file "${framework-resources}/res.txt")
+set(framework-flat-resource-file "${framework-resources}/flatresource.txt")
+set(framework-deep-resource-file "${framework-resources}/deep/deepresource.txt")
set(framework-library "${framework-dir}/Framework")
set(framework-versions "${framework-dir}/Versions")
+set(framework-some-file "${framework-versions}/Current/somedir/some.txt")
set(plist-file "${framework-resources}/Info.plist")
set(framework-header "${framework-dir}/Headers/foo.h")
@@ -22,6 +25,18 @@ if(NOT EXISTS ${framework-resource-file})
message(SEND_ERROR "Framework resource file not found at ${framework-resource-file}")
endif()
+if(NOT EXISTS ${framework-flat-resource-file})
+ message(SEND_ERROR "Framework flat resource file not found at ${framework-flat-resource-file}")
+endif()
+
+if(NOT EXISTS ${framework-deep-resource-file})
+ message(SEND_ERROR "Framework deep resource file not found at ${framework-deep-resource-file}")
+endif()
+
+if(NOT EXISTS ${framework-some-file})
+ message(SEND_ERROR "Framework some file not found at ${framework-some-file}")
+endif()
+
if(NOT EXISTS ${framework-versions})
message(SEND_ERROR "Framework versions not found at ${framework-versions}")
endif()
diff --git a/Tests/RunCMake/Framework/deepresource.txt b/Tests/RunCMake/Framework/deepresource.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/Framework/deepresource.txt
diff --git a/Tests/RunCMake/Framework/flatresource.txt b/Tests/RunCMake/Framework/flatresource.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/Framework/flatresource.txt
diff --git a/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake b/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake
index b81a5f7..e068a3a 100644
--- a/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake
+++ b/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake
@@ -1,6 +1,9 @@
set(framework-dir "${RunCMake_TEST_BINARY_DIR}/Framework.framework")
set(framework-resources "${framework-dir}/Resources")
set(framework-resource-file "${framework-dir}/res.txt")
+set(framework-flat-resource-file "${framework-dir}/flatresource.txt")
+set(framework-deep-resource-file "${framework-dir}/deep/deepresource.txt")
+set(framework-some-file "${framework-dir}/somedir/some.txt")
set(framework-library "${framework-dir}/Framework")
set(framework-versions "${framework-dir}/Versions")
set(plist-file "${framework-dir}/Info.plist")
@@ -22,6 +25,18 @@ if(NOT EXISTS ${framework-resource-file})
message(SEND_ERROR "Framework resource file not found at ${framework-resource-file}")
endif()
+if(NOT EXISTS ${framework-flat-resource-file})
+ message(SEND_ERROR "Framework flat resource file not found at ${framework-flat-resource-file}")
+endif()
+
+if(NOT EXISTS ${framework-deep-resource-file})
+ message(SEND_ERROR "Framework deep resource file not found at ${framework-deep-resource-file}")
+endif()
+
+if(NOT EXISTS ${framework-some-file})
+ message(SEND_ERROR "Framework some file not found at ${framework-some-file}")
+endif()
+
if(EXISTS ${framework-versions})
message(SEND_ERROR "Framework versions found at ${framework-versions}")
endif()
diff --git a/Tests/RunCMake/Framework/some.txt b/Tests/RunCMake/Framework/some.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/Framework/some.txt