diff --git a/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst b/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst index d185d91978..ee5624ab14 100644 --- a/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst +++ b/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst @@ -28,3 +28,8 @@ 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. + +.. versionadded:: 4.1 + + ``MACOSX_PACKAGE_LOCATION`` may be set on a source directory + to copy its entire tree into the bundle. diff --git a/Help/release/dev/macos-bundle-content-dir.rst b/Help/release/dev/macos-bundle-content-dir.rst new file mode 100644 index 0000000000..02c4d6fe60 --- /dev/null +++ b/Help/release/dev/macos-bundle-content-dir.rst @@ -0,0 +1,6 @@ +macos-bundle-content-dir +------------------------ + +* The :prop_sf:`MACOSX_PACKAGE_LOCATION` source file property now + works when set on a source directory, and copies its entire tree + into the bundle. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 29f0d70389..8f9a471dd1 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -419,20 +419,30 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild( void cmGlobalNinjaGenerator::AddMacOSXContentRule() { - cmNinjaRule rule("COPY_OSX_CONTENT"); - rule.Command = cmStrCat(this->CMakeCmd(), " -E copy $in $out"); - rule.Description = "Copying OS X Content $out"; - rule.Comment = "Rule for copying OS X bundle content file."; - this->AddRule(rule); + { + cmNinjaRule rule("COPY_OSX_CONTENT_FILE"); + rule.Command = cmStrCat(this->CMakeCmd(), " -E copy $in $out"); + rule.Description = "Copying OS X Content $out"; + rule.Comment = "Rule for copying OS X bundle content file, with style."; + this->AddRule(rule); + } + { + cmNinjaRule rule("COPY_OSX_CONTENT_DIR"); + rule.Command = cmStrCat(this->CMakeCmd(), " -E copy_directory $in $out"); + rule.Description = "Copying OS X Content $out"; + rule.Comment = "Rule for copying OS X bundle content dir, with style."; + this->AddRule(rule); + } } - void cmGlobalNinjaGenerator::WriteMacOSXContentBuild(std::string input, std::string output, std::string const& config) { this->AddMacOSXContentRule(); { - cmNinjaBuild build("COPY_OSX_CONTENT"); + cmNinjaBuild build(cmSystemTools::FileIsDirectory(input) + ? "COPY_OSX_CONTENT_DIR" + : "COPY_OSX_CONTENT_FILE"); build.Outputs.push_back(std::move(output)); build.ExplicitDeps.push_back(std::move(input)); this->WriteBuild(*this->GetImplFileStream(config), build); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 21c1d19205..e682efc52f 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -617,7 +617,9 @@ void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()( this->Generator->LocalGenerator->AppendEcho( commands, copyEcho, cmLocalUnixMakefileGenerator3::EchoBuild); std::string copyCommand = - cmStrCat("$(CMAKE_COMMAND) -E copy ", + cmStrCat(cmSystemTools::FileIsDirectory(input) + ? "$(CMAKE_COMMAND) -E copy_directory " + : "$(CMAKE_COMMAND) -E copy ", this->Generator->LocalGenerator->ConvertToOutputFormat( input, cmOutputConverter::SHELL), ' ', diff --git a/Tests/RunCMake/Framework/FrameworkLayout.cmake b/Tests/RunCMake/Framework/FrameworkLayout.cmake index e230e073e7..49756847b6 100644 --- a/Tests/RunCMake/Framework/FrameworkLayout.cmake +++ b/Tests/RunCMake/Framework/FrameworkLayout.cmake @@ -9,6 +9,7 @@ add_library(Framework ${FRAMEWORK_TYPE} res.txt flatresource.txt deepresource.txt + assets some.txt) if("${CMAKE_FRAMEWORK}" STREQUAL "") set_target_properties(Framework PROPERTIES @@ -23,6 +24,7 @@ set_target_properties(Framework PROPERTIES 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(assets PROPERTIES MACOSX_PACKAGE_LOCATION Resources) set_source_files_properties(some.txt PROPERTIES MACOSX_PACKAGE_LOCATION somedir) add_custom_command(TARGET Framework POST_BUILD diff --git a/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake b/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake index b436128e3e..a72810eea3 100644 --- a/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake +++ b/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake @@ -3,6 +3,8 @@ 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-assets-dir "${framework-resources}/assets") +set(framework-assets-file "${framework-assets-dir}/asset.txt") set(framework-library "${framework-dir}/Framework") set(framework-versions "${framework-dir}/Versions") set(framework-some-file "${framework-versions}/Current/somedir/some.txt") @@ -39,6 +41,16 @@ if(NOT EXISTS ${framework-deep-resource-file}) return() endif() +if(NOT IS_DIRECTORY ${framework-assets-dir}) + set(RunCMake_TEST_FAILED "Framework assets directory not found at \n ${framework-assets-dir}") + return() +endif() + +if(NOT EXISTS ${framework-assets-file}) + set(RunCMake_TEST_FAILED "Framework asset file not found at \n ${framework-assets-file}") + return() +endif() + if(NOT EXISTS ${framework-some-file}) set(RunCMake_TEST_FAILED "Framework some file not found at \n ${framework-some-file}") return() diff --git a/Tests/RunCMake/Framework/assets/asset.txt b/Tests/RunCMake/Framework/assets/asset.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake b/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake index be9a5fe1a5..5d373fd72c 100644 --- a/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake +++ b/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake @@ -3,6 +3,8 @@ 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-assets-dir "${framework-dir}/assets") +set(framework-assets-file "${framework-assets-dir}/asset.txt") set(framework-some-file "${framework-dir}/somedir/some.txt") set(framework-library "${framework-dir}/Framework") set(framework-versions "${framework-dir}/Versions") @@ -39,6 +41,16 @@ if(NOT EXISTS ${framework-deep-resource-file}) return() endif() +if(NOT IS_DIRECTORY ${framework-assets-dir}) + set(RunCMake_TEST_FAILED "Framework assets directory not found at \n ${framework-assets-dir}") + return() +endif() + +if(NOT EXISTS ${framework-assets-file}) + set(RunCMake_TEST_FAILED "Framework asset file not found at \n ${framework-assets-file}") + return() +endif() + if(NOT EXISTS ${framework-some-file}) set(RunCMake_TEST_FAILED "Framework some file not found at\n ${framework-some-file}") return()