[CMake] copy targets into bundles
Stephan Diederich
stephan.diederich at googlemail.com
Sat Nov 22 14:13:36 EST 2008
On Sat, Nov 22, 2008 at 7:00 PM, Stephan Diederich
<stephan.diederich at googlemail.com> wrote:
> Hi,
>
> I've a CMakeLists.txt which creates two executable tagets. One of them
> is a bundle, the other a command-line utility. Now I want to have (at
> best during build) the helper utility copied into the Resources folder
> of the bundle. I could not find a straightforward way of doing this.
>
> With source files this works out of the box:
> add_executable(MyBundle MACOSX_BUNDLE main.mm test.xml)
> set_source_files_properties(test.xml PROPERTIES MACOSX_PACKAGE_LOCATION
> Resources)
>
> But how to do it with cmake targets?
>
> The pretty much stripped down version of my CMakeLists.txt:
> add_executable(helperapp main.cpp)
> add_executable(MyBundle MACOSX_BUNDLE main.mm)
> #do something to copy helperapp to MyBundle.app/Contents/Resources
I made some progress and this seems to work:
add_executable(helperapp main.cpp)
add_executable(MyBundle MACOSX_BUNDLE main.mm )
#and copy helper into it. For now by hand.
#LOCATION seems to miss the .app fix that later..
get_target_property(MF_LOCATION MyBundle LOCATION)
get_target_property(HELPER_LOCATION helperapp LOCATION)
ADD_DEPENDENCIES(MyBundle helperapp)
add_custom_command(TARGET MyBundle
POST_BUILD
COMMAND mkdir -p ${MF_LOCATION}.app/Contents/Resources/
COMMAND cp ${HELPER_LOCATION}
${MF_LOCATION}.app/Contents/Resources/
COMMENT "add helper" VERBATIM)
still curious if this can be done better...
cheers,
stephan
More information about the CMake
mailing list