Quantcast

Bundling for OS X

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Bundling for OS X

Robert J. Hansen
(Full source is available at https://github.com/rjhansen/sherpa )

I have a Qt 5.7 application which I'm trying to migrate from qmake to
cmake 3.7.  So far it almost works on OS X, except when it comes to
making a proper app bundle.

The relevant contents of my CMakeLists.txt are as follows:

=====
install(DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION
${plugin_dest_dir}/plugins COMPONENT Runtime)

install(CODE "
    file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"\")
    " COMPONENT Runtime)

set(DIRS ${QT_LIBRARY_DIRS})

install(CODE "
    file(GLOB_RECURSE QTPLUGINS

\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
    include(BundleUtilities)
    fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\")
    " COMPONENT Runtime)

# To Create a package, one can run "cpack -G DragNDrop
CPackConfig.cmake" on Mac OS X
# where CPackConfig.cmake is created by including CPack
# And then there's ways to customize this as well
set(CPACK_BINARY_DRAGNDROP ON)
include(CPack)
=====



Some of this was taken from CMake's example Qt4/OS X application, but
Qt5 changed enough that the Qt4 example doesn't quite work.  Although it
creates an app bundle, the linkage points all over the map:



=====
quorra:Sherpa rjh$ otool -L Sherpa.app/Contents/MacOS/Sherpa
Sherpa.app/Contents/MacOS/Sherpa:
        @rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version
5.7.0, current version 5.7.0)
        /usr/local/lib/libgpgme.11.dylib (compatibility version 29.0.0, current
version 29.0.0)
        /usr/local/lib/libassuan.0.dylib (compatibility version 8.0.0, current
version 8.3.0)
        /usr/local/opt/libgpg-error/lib/libgpg-error.0.dylib (compatibility
version 22.0.0, current version 22.0.0)
        /usr/local/opt/minizip/lib/libminizip.1.dylib (compatibility version
2.0.0, current version 2.0.0)
        @rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.7.0,
current version 5.7.0)
        @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.7.0,
current version 5.7.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version
307.4.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 1238.0.0)
=====



Qt comes with a tool, macdeployqt, which seems to mangle the app bundle
beyond reason:



=====
quorra:Sherpa rjh$ ~/Qt5.7.0/5.7/clang_64/bin/macdeployqt Sherpa.app
quorra:Sherpa rjh$ open Sherpa.app
LSOpenURLsWithRole() failed with error -10810 for the file
/Users/rjh/Projects/Sherpa/Sherpa.app.
=====


Although macdeployqt *appears* to copy and relink things correctly,
invoking the binary directly yields the problem: "dyld: initializer
function 0x1082cfbd5 not in mapped image for
/usr/local/lib/libgpg-error.0.dylib" -- whatever that means.

tl;dr -- How can I copy my libraries (GPGME_LIBRARY, ASSUAN_LIBRARY,
GPGERR_LIBRARY, MINIZIP_LIBRARY, as well as QtWidgets, QtCore, and
QtGui) into the bundle and run install_name_tool to correctly relink the
application to the in-bundle libs?
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Loading...