You will need to look into the "BundleUtilities" functionality, specifically the "fixup_bundle()" function. This will copy and fixup dependent dylibs/frameworks needed by your project. There is a short example that uses Qt that you can download.
You will also probably need to properly configure a plist that resides in your Application bundle. THere are CMake variables for this that you can set then CMake will create a default plist for you. There are a number of examples, CMake itself is one, that uses the "fixup_bundle()" in its own code. Separate from all of that is all the CPack variables that you probably need to set. Here is a macro that I wrote for one of my own projects: #------------------------------------------------------------------------------- # This macro will set all the variables necessary to have a "good" OS X Application # bundle. The variables are as follows: # PROJECT_NAME - which can be taken from the ${PROJECT_NAME} variable is needed # DEBUG_EXTENSION - The extension used to denote a debug built Application. Typically # this is '_debug' # ICON_FILE_PATH - The complete path to the bundle icon file # VERSION_STRING - The version string that you wish to use for the bundle. For OS X # this string is usually XXXX.YY.ZZ in type. Look at the Apple docs for more info #------------------------------------------------------------------------------- macro(ConfigureMacOSXBundlePlist PROJECT_NAME DEBUG_EXTENSION ICON_FILE_PATH VERSION_STRING) # message(STATUS "ConfigureMacOSXBundlePlist for ${PROJECT_NAME} ") IF(CMAKE_BUILD_TYPE MATCHES "Release") SET(DBG_EXTENSION "") else() set(DBG_EXTENSION ${DEBUG_EXTENSION}) endif() get_filename_component(ICON_FILE_NAME "${ICON_FILE_PATH}" NAME) #CFBundleGetInfoString SET(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME}${DBG_EXTENSION} Version ${VERSION_STRING}, Copyright 2009 BlueQuartz Software.") SET(MACOSX_BUNDLE_ICON_FILE ${ICON_FILE_NAME}) SET(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_NAME}${DBG_EXTENSION}") #CFBundleLongVersionString SET(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME}${DBG_EXTENSION} Version ${VERSION_STRING}") SET(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME}${DBG_EXTENSION}) SET(MACOSX_BUNDLE_SHORT_VERSION_STRING ${VERSION_STRING}) SET(MACOSX_BUNDLE_BUNDLE_VERSION ${VERSION_STRING}) SET(MACOSX_BUNDLE_COPYRIGHT "Copyright 2010, BlueQuartz Software. All Rights Reserved.") SET(${PROJECT_NAME}_PROJECT_SRCS ${${PROJECT_NAME}_PROJECT_SRCS} ${ICON_FILE_PATH}) SET_SOURCE_FILES_PROPERTIES(${ICON_FILE_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) endmacro() Hope that helps ___________________________________________________________ Mike Jackson www.bluequartz.net Principal Software Engineer mike.jack...@bluequartz.net BlueQuartz Software Dayton, Ohio On Jan 19, 2011, at 7:08 AM, Yngve Inntjore Levinsen wrote: > 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 > _______________________________________________ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake