[CMake] Installing OSX Frameworks

Shead, Timothy tshead at sandia.gov
Tue Jul 22 19:58:32 EDT 2008


On 7/22/08 10:56 AM, "Mike Arthur" <mike at mikearthur.co.uk> wrote:

> Has anyone worked out a nice way of installing the needed OSX frameworks into
> my application bundle?

If you use the (bleeding-edge) CPack bundle generator, you can install
frameworks (or any other dependency) using normal CMake install commands:

INSTALL(
  DIRECTORY
    ${QT_LIBRARY_DIR}/QtAssistant.framework
    ${QT_LIBRARY_DIR}/QtCore.framework
    ${QT_LIBRARY_DIR}/QtDesigner.framework
    ${QT_LIBRARY_DIR}/QtGui.framework
    ${QT_LIBRARY_DIR}/QtNetwork.framework
    ${QT_LIBRARY_DIR}/QtScript.framework
    ${QT_LIBRARY_DIR}/QtSql.framework
    ${QT_LIBRARY_DIR}/QtSvg.framework
    ${QT_LIBRARY_DIR}/QtXml.framework
  USE_SOURCE_PERMISSIONS
  DESTINATION Frameworks
  )

You would then use a custom startup command for your bundle that ensures the
"real" executable can find the installed resources:

#!/bin/sh
BUNDLE="`echo "$0" | sed -e 's/\/Contents\/MacOS\/.*//'`"
RESOURCES="$BUNDLE/Contents/Resources"

export DYLD_FRAMEWORK_PATH=$RESOURCES/Frameworks
export DYLD_LIBRARY_PATH=$RESOURCES/bin

exec "$RESOURCES/bin/my_real_application"

This works fine for most applications, but there are a couple of known
issues to consider:

* This installs the frameworks to Bundle/Contents/Resources/Frameworks, my
understanding is that the "officially sanctioned" location for frameworks in
bundles is Bundle/Contents/Frameworks.

* As others have pointed-out, setting DYLD_FRAMEWORK_PATH and
DYLD_LIBRARY_PATH can cause subtle problems if your main application spawns
other processes.

I hope to get these issues taken-care-of eventually, suggestions welcome.

Cheers,
Tim

--
Timothy M. Shead
Scalable Analytics & Visualization (1424)
Sandia National Laboratories
505-284-0139





More information about the CMake mailing list