[CMake] Preserving resource directory structure on bundle level in OSX and iOS

Daniel Dekkers d.dekkers at cthrough.nl
Thu Jun 14 07:05:14 EDT 2012


Hi,

If we add a set of resources to an application (OSX or iOS) with...

ADD_EXECUTABLE( ${APPNAME} MACOSX_BUNDLE ${ALLSOURCES} ${ALLRESOURCES} )

... where ALLRESOURCES contains references with complete paths (ie /path/rsrc/images/image.png, /path/rsrc/xml/data.xml, etc...)
and label these files as resources...

SET_TARGET_PROPERTIES( ${APPNAME} PROPERTIES RESOURCE "${ALLRESOURCES}" )

after having "grouped" them...

SOURCE_GROUP("Application/rsrc/xml" FILES ... )
SOURCE_GROUP("Application/rsrc/images" FILES ... )

... the files show up correctly in Xcode and are copied to the application bundle(s) (by Xcode, no POST_BUILD copy command).

But.. the hierarchy is flattened and gets lost on bundle level.

For an iOS application, the resources end up in APPNAME.app (directly in the root of the bundle, together with everything else).
For an OSX application, the resources end up in APPNAME.app/Contents/Resources (dedicated resources container).

Someone knows a way to preserve the hierarchy in the bundle?

For iOS something like:
APPNAME.app/rsrc/images/image.png
APPNAME.app/rsrc/xml/data.xml

and for OSX something like:

APPNAME.app/Contents/Resources/rsrc/images/image.png
APPNAME.app/Contents/Resources/rsrc/xml/data.xml

Thanks,
Daniel










More information about the CMake mailing list