[CMake] cpack bundle on osx

Yngve Inntjore Levinsen yngve.levinsen at gmail.com
Wed Jan 19 07:08:09 EST 2011


Dear fellow cmake users,

I am trying to create a bundle of my project that I build using CMake. I 
have tried using the DragNDrop generator, which works to some extent. I 
do manage to create a .app folder which contains the one binary that is 
the outcome of the project in the Contents/MacOS folder. I do also 
create a .dmg file. However:
- When clicking the .dmg I am first presented with the license (great!) 
before the dmg is mounted and I see an empty folder (??)
- When clicking on the <package>.app nothing happens. However, clicking 
on the binary in Contents/MacOS works as expected.
- I would also like to know how to include the shared libraries (dylib) 
that I need. I currently depend on stuff that is installed with 
MacPorts, and I don't want to require that the user have to install all 
that stuff. Isn't the bundle supposed to be "self-contained"? Ideally I 
would like the bundle to automatically include the libraries that are 
listed with the "otools -L <binary>" command...

Question: Where do I find the DragNDrop documentation/examples? On the 
wiki ( 
http://www.paraview.org/Wiki/CMake:CPackPackageGenerators#DragNDrop_.28OSX_only.29 
) there are only two small lines, and my googling skills are apparently 
not good enough..

Here is an extraction of the relevant part of my CMakeLists.txt:
...
if(APPLE)
   add_executable(madx${BINARY_POSTFIX} MACOSX_BUNDLE ${srcfiles})
   SET_TARGET_PROPERTIES(madx${BINARY_POSTFIX} PROPERTIES 
CPACK_BUNDLE_STARTUP_COMMAND madx${BINARY_POSTFIX})
   SET_TARGET_PROPERTIES(madx${BINARY_POSTFIX} PROPERTIES 
CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/cmakesrc/MadX.icns")
else(APPLE)
   add_executable(madx${BINARY_POSTFIX} ${srcfiles})
endif(APPLE)
...

I also set some CPACK_BUNDLE properties because I earlier on tried to 
use the BUNDLE generator, but from what I understand this should have 
nothing to do with the DragNDrop generator?

Thank you all for reading and thanks in advance for all help you might 
provide!

Cheers,
Yngve


More information about the CMake mailing list