[cmake-developers] Create subdirectories in Resource directory for Frameworks and Application bundle.

Clinton Stimpson clinton at elemtech.com
Fri Dec 11 13:06:04 EST 2015



On Friday, December 11, 2015 05:01:41 PM Bartosz Kosiorek wrote:
> Thanks Clint
> 
> Unfortunately MACOSX_PACKAGE_LOCATION is not working correctly with RESOURCE
> property. For every resource which is marked as RESOURCE, will be placed in
> root "Resources" directory.
> 
> The CMake code below create following directory structure for OS X:
> 
> ── mul.framework
>     ├── Headers -> Versions/Current/Headers
>     ├── Resources -> Versions/Current/Resources
>     ├── Versions
>     │   ├── A
>     │   │   ├── Headers
>     │   │   │   └── mul.h
>     │   │   ├── Modules
>     │   │   │   └── module.modulemap
>     │   │   ├── Resources
>     │   │   │   ├── Info.plist
>     │   │   │   ├── mulres.txt
>     │   │   │   ├── pl.txt
>     │   │   │   └── resourcefile.txt
>     │   │   ├── lang
>     │   │   │   └── en.txt
>     │   │   └── mul
>     │   └── Current -> A
>     └── mul -> Versions/Current/mul
> 
> 
> As you can see eveything which is marked as "RESOURCE" will be placed in
> Versions/A/ directory My expectation will be that lang/pl.txt and
> lang/en.txt should be in Resources/lang/ directory. Here is complete
> directory structure:
> 
> ── mul.framework
>     ├── Headers -> Versions/Current/Headers
>     ├── Resources -> Versions/Current/Resources
>     ├── Versions
>     │   ├── A
>     │   │   ├── Headers
>     │   │   │   └── mul.h
>     │   │   ├── Modules
>     │   │   │   └── module.modulemap
>     │   │   ├── Resources
>     │   │   │   ├── Info.plist
>     │   │   │   ├── mulres.txt
>     │   │   │   ├── lang
>     │   │   │   │   └── pl.txt
>     │   │   │   │   └── en.txt
>     │   │   │   └── resourcefile.txt
>     │   │   ├── lang
>     │   │   │   └── en.txt
>     │   │   └── mul
>     │   └── Current -> A
>     └── mul -> Versions/Current/mul
> 
> 
> What do you think about that?
> 
> Here is the source code:
> 
> set_property(SOURCE module.modulemap
>   PROPERTY MACOSX_PACKAGE_LOCATION "Modules")
> 
> set_property(
>   SOURCE lang/en.txt lang/pl.txt
>   PROPERTY MACOSX_PACKAGE_LOCATION "lang")
> 
> set(RESLIST
>     mulres.txt
>     lang/pl.txt
>     resourcefile.txt
>     )
> 
> add_library(mul SHARED
>             mul.c
>             mul.h
>             module.modulemap
>             lang/pl.txt
>             lang/en.txt
>             resourcefile.txt
>             mulres.txt)
> 
> # Create an iOS Framework bundle
> set_target_properties(mul PROPERTIES
>   FRAMEWORK TRUE
>   MACOSX_FRAMEWORK_IDENTIFIER org.cmake.mul
>   MACOSX_FRAMEWORK_SHORT_VERSION_STRING 42
>   MACOSX_FRAMEWORK_BUNDLE_VERSION 3.2.10
>   XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
>   PUBLIC_HEADER mul.h
>   RESOURCE "${RESLIST}"
> )


Here is a CMakeLists.txt that will give you the desired layout.
I also see that MACOSX_PACKAGE_LOCATION doesn't work with RESOURCE.


set_property(SOURCE module.modulemap
  PROPERTY MACOSX_PACKAGE_LOCATION "Modules")

set_property(
  SOURCE lang/pl.txt lang/en.txt
  PROPERTY MACOSX_PACKAGE_LOCATION "Resources/lang")

set(RESLIST 
    mulres.txt
    resourcefile.txt
    )

add_library(mul SHARED 
            mul.c
            mul.h
            module.modulemap
            lang/pl.txt
            lang/en.txt
            resourcefile.txt
            mulres.txt)

# Create an iOS Framework bundle 
set_target_properties(mul PROPERTIES
  FRAMEWORK TRUE
  MACOSX_FRAMEWORK_IDENTIFIER org.cmake.mul
  MACOSX_FRAMEWORK_SHORT_VERSION_STRING 42
  MACOSX_FRAMEWORK_BUNDLE_VERSION 3.2.10
  XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
  PUBLIC_HEADER mul.h
  RESOURCE "${RESLIST}"
)


Now I'm wondering what does the RESOURCE target property do that 
MACOSX_PACKAGE_LOCATION doesn't already support?

Clint


More information about the cmake-developers mailing list