Merge topic 'ios-framework-resource-layout'
e76ee2c0
iOS: Fix framework resource directory layout (#15848)
This commit is contained in:
commit
d4767fca96
|
@ -3,7 +3,7 @@ MACOSX_BUNDLE
|
|||
|
||||
Build an executable as an Application Bundle on OS X or iOS.
|
||||
|
||||
When this property is set to true the executable when built on OS X
|
||||
When this property is set to ``TRUE`` the executable when built on OS X
|
||||
or iOS will be created as an application bundle. This makes it
|
||||
a GUI executable that can be launched from the Finder. See the
|
||||
:prop_tgt:`MACOSX_FRAMEWORK_INFO_PLIST` target property for information about
|
||||
|
|
|
@ -3,8 +3,8 @@ MACOSX_RPATH
|
|||
|
||||
Whether this target on OS X or iOS is located at runtime using rpaths.
|
||||
|
||||
When this property is set to true, the directory portion of
|
||||
the "install_name" field of this shared library will be ``@rpath``
|
||||
When this property is set to ``TRUE``, the directory portion of
|
||||
the ``install_name`` field of this shared library will be ``@rpath``
|
||||
unless overridden by :prop_tgt:`INSTALL_NAME_DIR`. This indicates
|
||||
the shared library is to be found at runtime using runtime
|
||||
paths (rpaths).
|
||||
|
@ -18,6 +18,6 @@ can be controlled by the :prop_tgt:`INSTALL_RPATH` target property on
|
|||
the target linking to this target.
|
||||
|
||||
Policy :policy:`CMP0042` was introduced to change the default value of
|
||||
``MACOSX_RPATH`` to ``TRUE. This is because use of ``@rpath`` is a
|
||||
``MACOSX_RPATH`` to ``TRUE``. This is because use of ``@rpath`` is a
|
||||
more flexible and powerful alternative to ``@executable_path`` and
|
||||
``@loader_path``.
|
||||
|
|
|
@ -1,11 +1,61 @@
|
|||
RESOURCE
|
||||
--------
|
||||
|
||||
Specify resource files in a :prop_tgt:`FRAMEWORK` shared library target.
|
||||
Specify resource files in a :prop_tgt:`FRAMEWORK` or :prop_tgt:`BUNDLE`.
|
||||
|
||||
Shared library targets marked with the :prop_tgt:`FRAMEWORK` property generate
|
||||
frameworks on OS X, iOS and normal shared libraries on other platforms.
|
||||
This property may be set to a list of files to be placed in the
|
||||
``Resources`` directory inside the framework folder. On non-Apple
|
||||
platforms these files may be installed using the ``RESOURCE`` option to
|
||||
the ``install(TARGETS)`` command.
|
||||
Target marked with the :prop_tgt:`FRAMEWORK` or :prop_tgt:`BUNDLE` property
|
||||
generate framework or application bundle (both OS X and iOS is supported)
|
||||
or normal shared libraries on other platforms.
|
||||
This property may be set to a list of files to be placed in the corresponding
|
||||
directory (eg. ``Resources`` directory for OS X) inside the bundle.
|
||||
On non-Apple platforms these files may be installed using the ``RESOURCE``
|
||||
option to the ``install(TARGETS)`` command.
|
||||
|
||||
Following example of Application Bundle:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
add_executable(ExecutableTarget
|
||||
addDemo.c
|
||||
resourcefile.txt
|
||||
appresourcedir/appres.txt
|
||||
)
|
||||
|
||||
target_link_libraries(ExecutableTarget heymath mul)
|
||||
|
||||
set(RESOURCE_FILES
|
||||
resourcefile.txt
|
||||
appresourcedir/appres.txt
|
||||
)
|
||||
|
||||
set_target_properties(ExecutableTarget PROPERTIES
|
||||
MACOSX_BUNDLE TRUE
|
||||
MACOSX_FRAMEWORK_IDENTIFIER org.cmake.ExecutableTarget
|
||||
RESOURCE "${RESOURCE_FILES}"
|
||||
)
|
||||
|
||||
will produce flat structure for iOS systems::
|
||||
|
||||
ExecutableTarget.app
|
||||
appres.txt
|
||||
ExecutableTarget
|
||||
Info.plist
|
||||
resourcefile.txt
|
||||
|
||||
For OS X systems it will produce following directory structure::
|
||||
|
||||
ExecutableTarget.app/
|
||||
Contents
|
||||
Info.plist
|
||||
MacOS
|
||||
ExecutableTarget
|
||||
Resources
|
||||
appres.txt
|
||||
resourcefile.txt
|
||||
|
||||
For Linux, such cmake script produce following files::
|
||||
|
||||
ExecutableTarget
|
||||
Resources
|
||||
appres.txt
|
||||
resourcefile.txt
|
||||
|
|
|
@ -3752,7 +3752,11 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
|
|||
if(cmSourceFile* sf = this->Makefile->GetSource(*it))
|
||||
{
|
||||
SourceFileFlags& flags = this->SourceFlagsMap[sf];
|
||||
flags.MacFolder = "Resources";
|
||||
flags.MacFolder = "";
|
||||
if(!this->Makefile->PlatformIsAppleIos())
|
||||
{
|
||||
flags.MacFolder = "Resources";
|
||||
}
|
||||
flags.Type = cmGeneratorTarget::SourceFileTypeResource;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
cmake_minimum_required(VERSION 3.4)
|
||||
enable_language(C)
|
||||
|
||||
add_library(Framework SHARED foo.c)
|
||||
set_target_properties(Framework PROPERTIES FRAMEWORK TRUE)
|
||||
add_library(Framework SHARED
|
||||
foo.c
|
||||
foo.h
|
||||
res.txt)
|
||||
set_target_properties(Framework PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
PUBLIC_HEADER foo.h
|
||||
RESOURCE "res.txt")
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
set(framework-dir "${RunCMake_TEST_BINARY_DIR}/Framework.framework")
|
||||
set(plist-file "${framework-dir}/Resources/Info.plist")
|
||||
set(framework-resources "${framework-dir}/Resources")
|
||||
set(framework-resource-file "${framework-resources}/res.txt")
|
||||
set(framework-library "${framework-dir}/Framework")
|
||||
set(framework-versions "${framework-dir}/Versions")
|
||||
set(plist-file "${framework-resources}/Info.plist")
|
||||
set(framework-header "${framework-dir}/Headers/foo.h")
|
||||
|
||||
if(NOT IS_DIRECTORY ${framework-dir})
|
||||
message(SEND_ERROR "Framework not found at ${framework-dir}")
|
||||
|
@ -15,6 +18,18 @@ if(NOT EXISTS ${framework-library})
|
|||
message(SEND_ERROR "Framework library not found at ${framework-library}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${framework-resource-file})
|
||||
message(SEND_ERROR "Framework resource file not found at ${framework-resource-file}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${framework-versions})
|
||||
message(SEND_ERROR "Framework versions not found at ${framework-versions}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${framework-resources})
|
||||
message(SEND_ERROR "Framework Resources not found at ${framework-resources}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${framework-header})
|
||||
message(SEND_ERROR "Framework header file not found at ${framework-header}")
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
int foo();
|
|
@ -1,7 +1,10 @@
|
|||
set(framework-dir "${RunCMake_TEST_BINARY_DIR}/Framework.framework")
|
||||
set(plist-file "${framework-dir}/Info.plist")
|
||||
set(framework-resources "${framework-dir}/Resources")
|
||||
set(framework-resource-file "${framework-dir}/res.txt")
|
||||
set(framework-library "${framework-dir}/Framework")
|
||||
set(framework-versions "${framework-dir}/Versions")
|
||||
set(plist-file "${framework-dir}/Info.plist")
|
||||
set(framework-header "${framework-dir}/Headers/foo.h")
|
||||
|
||||
if(NOT IS_DIRECTORY ${framework-dir})
|
||||
message(SEND_ERROR "Framework not found at ${framework-dir}")
|
||||
|
@ -15,6 +18,18 @@ if(NOT EXISTS ${framework-library})
|
|||
message(SEND_ERROR "Framework library not found at ${framework-library}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${framework-resource-file})
|
||||
message(SEND_ERROR "Framework resource file not found at ${framework-resource-file}")
|
||||
endif()
|
||||
|
||||
if(EXISTS ${framework-versions})
|
||||
message(SEND_ERROR "Framework versions found at ${framework-versions}")
|
||||
endif()
|
||||
|
||||
if(EXISTS ${framework-resources})
|
||||
message(SEND_ERROR "Framework Resources found at ${framework-resources}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${framework-header})
|
||||
message(SEND_ERROR "Framework headers not found at ${framework-header}")
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue