mirror of
https://github.com/Kitware/CMake.git
synced 2025-05-08 22:37:04 +08:00
Merge topic 'macos-bundle-content-dir'
6b3ec3fefb Ninja/Makefile: Add support for copying directories into Apple bundles Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !10508
This commit is contained in:
commit
54b548df7b
@ -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.
|
||||
|
6
Help/release/dev/macos-bundle-content-dir.rst
Normal file
6
Help/release/dev/macos-bundle-content-dir.rst
Normal file
@ -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.
|
@ -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);
|
||||
|
@ -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),
|
||||
' ',
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
0
Tests/RunCMake/Framework/assets/asset.txt
Normal file
0
Tests/RunCMake/Framework/assets/asset.txt
Normal file
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user