User:Tshead/OSX CPack Bundle Generator: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
== OverView ==
== OverView ==


Using CMake, I support several cross-platform projects that are deployed on Linux, OSX, and Windows.  Some of these projects use Qt, others use GTK.  On OSX, I prefer distribution via "bundles" over PackageMaker, but I require more flexibility than the OSXX11 generator provides.  For example, projects based on Qt don't need / don't want the functionality to auto-start X11 when the bundle is openedOther projects need to run a shell-script at startup to setup a special environment.  Some projects require an Info.plist that is more complex than that provided via the current generator.
Using CMake, I support several cross-platform projects that are deployed on Linux, OSX, and Windows.  Some of these projects use Qt, others use GTK.  On OSX, I prefer distribution via "bundles" over PackageMaker, but I require more flexibility than the OSXX11 generator provides.  For example, GTK projects need to start X11 before the "real" application starts, while Qt projects don't require this functionality.  In both cases, setting DYLD_LIBRARY_PATH at startup eliminates the need to run install_name_tool on libraries included in the bundle.  Some projects require an Info.plist that is more complex than that provided via the current generator.  All projects should integrate well with CMake's existing installation functionality.


To do this in the past, I've used "CreateBundle.sh.in" custom shell scripts to do the work of creating bundles, but this is repetitive and error-prone, and it does not integrate well with CMake INSTALL() functionality.  What's needed is a more flexible OSX bundle generator for CPack.
To do this in the past, I've used "CreateBundle.sh.in" custom shell scripts to do the work of creating bundles, but this is repetitive and error-prone, and it bypasses CMake installation.  What's needed is a more flexible OSX bundle generator for CPack.


== Prototype ==
== Prototype ==


You can get a patch for CMake that includes the prototype bundle generator from the CMake bugtracker at http://public.kitware.com/Bug/view.php?id=7170
You can get a patch for CMake that includes the prototype bundle generator from the CMake bugtracker at http://public.kitware.com/Bug/view.php?id=7170
== Behavior ==
* The prototype generator creates an OSX bundle with the following layout:
${CPACK_BUNDLE_NAME}/
  Contents/
    MacOS/
      ${CPACK_BUNDLE_NAME} (copied from ${CPACK_BUNDLE_STARTUP_COMMAND})
    Resources/
      (filesystem defined by CMake INSTALL commands)
    Info.plist (copied from ${CPACK_BUNDLE_PLIST})
* {CPACK_BUNDLE_STARTUP_COMMAND} is the name of a file that will be executed when the user opens the bundle.  It could be a binary or a script.  For most non-trivial applications, it will be a script:
** For Qt applications, the script sets DYLD_LIBRARY_PATH and executes one of the binaries installed in the Resources/. 
** For GTK applications, the script sets DYLD_LIBRARY_PATH, starts X11, and executes one of the binaries installed in Resources/.


== Required CMake Variables ==
== Required CMake Variables ==
Line 17: Line 33:
* CPACK_BUNDLE_NAME - provides the bundle name (displayed in the finder underneath the bundle icon).
* CPACK_BUNDLE_NAME - provides the bundle name (displayed in the finder underneath the bundle icon).
* CPACK_BUNDLE_ICON - provides the bundle icon (displayed in the /Applications folder, on the dock, etc).
* CPACK_BUNDLE_ICON - provides the bundle icon (displayed in the /Applications folder, on the dock, etc).
* CPACK_BUNDLE_PLIST - path to a file that will become the bundle plist (hard-coded, generated-elsewhere via CONFIGURE_FILE(), etc).
* CPACK_BUNDLE_PLIST - path to a file that will become the bundle plist.
* CPACK_BUNDLE_STARTUP_COMMAND - path to a file that will be executed when the user opens the bundle.  Could be a shell-script or a binary.
* CPACK_BUNDLE_STARTUP_COMMAND - path to a file that will be executed when the user opens the bundle.  Could be a shell-script or a binary.

Revision as of 15:59, 6 June 2008

OverView

Using CMake, I support several cross-platform projects that are deployed on Linux, OSX, and Windows. Some of these projects use Qt, others use GTK. On OSX, I prefer distribution via "bundles" over PackageMaker, but I require more flexibility than the OSXX11 generator provides. For example, GTK projects need to start X11 before the "real" application starts, while Qt projects don't require this functionality. In both cases, setting DYLD_LIBRARY_PATH at startup eliminates the need to run install_name_tool on libraries included in the bundle. Some projects require an Info.plist that is more complex than that provided via the current generator. All projects should integrate well with CMake's existing installation functionality.

To do this in the past, I've used "CreateBundle.sh.in" custom shell scripts to do the work of creating bundles, but this is repetitive and error-prone, and it bypasses CMake installation. What's needed is a more flexible OSX bundle generator for CPack.

Prototype

You can get a patch for CMake that includes the prototype bundle generator from the CMake bugtracker at http://public.kitware.com/Bug/view.php?id=7170

Behavior

  • The prototype generator creates an OSX bundle with the following layout:

${CPACK_BUNDLE_NAME}/

 Contents/
   MacOS/
     ${CPACK_BUNDLE_NAME} (copied from ${CPACK_BUNDLE_STARTUP_COMMAND})
   Resources/
     (filesystem defined by CMake INSTALL commands)
   Info.plist (copied from ${CPACK_BUNDLE_PLIST})
  • {CPACK_BUNDLE_STARTUP_COMMAND} is the name of a file that will be executed when the user opens the bundle. It could be a binary or a script. For most non-trivial applications, it will be a script:
    • For Qt applications, the script sets DYLD_LIBRARY_PATH and executes one of the binaries installed in the Resources/.
    • For GTK applications, the script sets DYLD_LIBRARY_PATH, starts X11, and executes one of the binaries installed in Resources/.

Required CMake Variables

The prototype bundle generator uses the following variables:

  • CPACK_PACKAGE_FILE_NAME - provides the name of the final compressed disk image (the name of the file that is distributed).
  • CPACK_PACKAGE_ICON - provides the icon for the mounted disk image (appears after the user mounts the disk image).
  • CPACK_BUNDLE_NAME - provides the bundle name (displayed in the finder underneath the bundle icon).
  • CPACK_BUNDLE_ICON - provides the bundle icon (displayed in the /Applications folder, on the dock, etc).
  • CPACK_BUNDLE_PLIST - path to a file that will become the bundle plist.
  • CPACK_BUNDLE_STARTUP_COMMAND - path to a file that will be executed when the user opens the bundle. Could be a shell-script or a binary.