[CMake] Packaging command-line + GUI tools on OS X

Sjoerd Cranen scranen at gmail.com
Mon Nov 17 11:13:50 EST 2014


Hi all,

I am trying to package a set of command line tools and some graphical tools, sharing the same libraries. Given how Apple wants people to use relocatable .app bundles, but advises to put command line tools in their usual *nix paths, I came up with the following intended paths for my files:

/Applications
  /foo.app
    /Contents
      /MacOS
        foo (linked to ../lib/bar.dylib)
      /lib -> (symlink to <INSTALL_ROOT>/lib

<INSTALL_ROOT>
  /lib
    bar.dylib
  /bin
    baz (linked to ../lib/bar.dylib)

Here, foo.app is a graphical app, bar a dynamic library and baz a command line app. I would like users to have the freedom to install into any directory they like (but default would be /usr or /usr/local). Especially because I would like to be able to deploy multiple versions of the tool suite simultaneously.

The suggested approach with the symlink causes the .app bundles to be relocatable, as long as the shared libraries are not moved. This is a compromise I am willing to make; the alternative is to have a private copy of each shared library per .app, defeating the point of shared libraries. As we have 5 .apps, and 80MB of shared libraries, making copies is not acceptable.

Is there a way to achieve the intended setup using CPack? I have been trying to use the PackageMaker generator, but I do not see how I could add in the symlink to the <INSTALL_ROOT>/lib dir, as this is path is only known when the package is installed. Early experiments with the CPACK_POSTFLIGHT_SCRIPT caused the installer to display the (unhelpful) error message “Something went wrong”, and I am not sure this feature is supported for new versions of OS X. Also, CMake complains about installing files in the absolute path /Applications; I am unsure if I can safely ignore these warnings.

I hope someone can point me in the right direction.

Best regards,
Sjoerd Cranen


More information about the CMake mailing list