From 797be30633c03949a8217b6da54e91470a144ccd Mon Sep 17 00:00:00 2001 From: Christophe VG Date: Mon, 2 Feb 2015 19:26:18 +0100 Subject: [PATCH] fixes issue #28, including imageformat libraries --- scripts/fix-plugins.sh | 62 +++++++++++++++++++++++++++++++++++++----- src/app/CMakeLists.txt | 21 +++++++------- 2 files changed, 66 insertions(+), 17 deletions(-) diff --git a/scripts/fix-plugins.sh b/scripts/fix-plugins.sh index 6cfc64d..c82b39e 100755 --- a/scripts/fix-plugins.sh +++ b/scripts/fix-plugins.sh @@ -1,13 +1,15 @@ #!/bin/bash -# script expects to be execute from the bundle directory (e.g. finFoil.app/) +# script expects to be executed from the bundle directory (e.g. finFoil.app/) # it takes two arguments: -LIBQCOCOA_DYLIB=$1 +PLUGINS_PATH=$1 FRAMEWORKS_PATH=$2 +LIB_DIR=/opt/local/lib # TODO: make this more generic + # install libqcocoa plugin mkdir -p Contents/PlugIns/platforms -cp ${LIBQCOCOA_DYLIB} Contents/PlugIns/platforms +cp ${PLUGINS_PATH}/platforms/libqcocoa.dylib Contents/PlugIns/platforms/ # fix identity and references to frameworks install_name_tool -id @executable_path/../PlugIns/platforms/libqcocoa.dylib Contents/PlugIns/platforms/libqcocoa.dylib @@ -18,10 +20,10 @@ install_name_tool -change ${FRAMEWORKS_PATH}/QtCore.framework/Versions/5/QtCore # fix for issue #28, macports seems to override the system version # TODO: check other situations, e.g. without MacPorts, with Homebrew,... -install_name_tool -change /opt/local/lib/libz.1.dylib @executable_path/../Frameworks/libz.1.dylib Contents/PlugIns/platforms/libqcocoa.dylib -install_name_tool -change /opt/local/lib/libgthread-2.0.0.dylib @executable_path/../Frameworks/libgthread-2.0.0.dylib Contents/PlugIns/platforms/libqcocoa.dylib -install_name_tool -change /opt/local/lib/libglib-2.0.0.dylib @executable_path/../Frameworks/libglib-2.0.0.dylib Contents/PlugIns/platforms/libqcocoa.dylib -install_name_tool -change /opt/local/lib/libintl.8.dylib @executable_path/../Frameworks/libintl.8.dylib Contents/PlugIns/platforms/libqcocoa.dylib +install_name_tool -change ${LIB_DIR}/libz.1.dylib @executable_path/../Frameworks/libz.1.dylib Contents/PlugIns/platforms/libqcocoa.dylib +install_name_tool -change ${LIB_DIR}/libgthread-2.0.0.dylib @executable_path/../Frameworks/libgthread-2.0.0.dylib Contents/PlugIns/platforms/libqcocoa.dylib +install_name_tool -change ${LIB_DIR}/libglib-2.0.0.dylib @executable_path/../Frameworks/libglib-2.0.0.dylib Contents/PlugIns/platforms/libqcocoa.dylib +install_name_tool -change ${LIB_DIR}/libintl.8.dylib @executable_path/../Frameworks/libintl.8.dylib Contents/PlugIns/platforms/libqcocoa.dylib # install QtPrintSupport framework cp -r ${FRAMEWORKS_PATH}/QtPrintSupport.framework Contents/Frameworks @@ -31,3 +33,49 @@ install_name_tool -id @executable_path/../Frameworks/QtPrintSupport.framework/Ve install_name_tool -change ${FRAMEWORKS_PATH}/QtWidgets.framework/Versions/5/QtWidgets @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets Contents/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport install_name_tool -change ${FRAMEWORKS_PATH}/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui Contents/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport install_name_tool -change ${FRAMEWORKS_PATH}/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore Contents/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport + +# fix for issue #28, missing imageformats +cp -r ${PLUGINS_PATH}/imageformats Contents/PlugIns/ + +# fix references to frameworks +for plugin in Contents/PlugIns/imageformats/*.dylib; do + install_name_tool -id @executable_path/../../${plugin} ${plugin} + install_name_tool -change ${FRAMEWORKS_PATH}/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui ${plugin} + install_name_tool -change ${FRAMEWORKS_PATH}/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore ${plugin} + install_name_tool -change ${FRAMEWORKS_PATH}/QtSvg.framework/Versions/5/QtSvg @executable_path/../Frameworks/QtSvg.framework/Versions/5/QtSvg ${plugin} + install_name_tool -change ${FRAMEWORKS_PATH}/QtWidgets.framework/Versions/5/QtWidgets @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets ${plugin} + # TODO: make these more generic + install_name_tool -change ${LIB_DIR}/libjpeg.9.dylib @executable_path/../Frameworks/libjpeg.9.dylib ${plugin} + install_name_tool -change ${LIB_DIR}/libmng.1.dylib @executable_path/../Frameworks/libmng.1.dylib ${plugin} + install_name_tool -change ${LIB_DIR}/libtiff.5.dylib @executable_path/../Frameworks/libtiff.5.dylib ${plugin} +done + +# also include some additional image processing libraries +# TODO: make this more generic -> use src files properties ? +NATIVE_IMG_LIBS="\ + libjpeg.9.dylib \ + libmng.1.dylib \ + libtiff.5.dylib \ + liblcms.1.dylib \ + liblzma.5.dylib" + +# copy and fix id and references in these addition libraries +for lib in ${NATIVE_IMG_LIBS}; do + cp ${LIB_DIR}/${lib} Contents/Frameworks/ + install_name_tool -id @executable_path/../../${lib} Contents/Frameworks/${lib} + # TODO: make these more generic + install_name_tool -change ${LIB_DIR}/libjpeg.9.dylib @executable_path/../Frameworks/libjpeg.9.dylib Contents/Frameworks/${lib} + install_name_tool -change ${LIB_DIR}/libmng.1.dylib @executable_path/../Frameworks/libmng.1.dylib Contents/Frameworks/${lib} + install_name_tool -change ${LIB_DIR}/libtiff.5.dylib @executable_path/../Frameworks/libtiff.5.dylib Contents/Frameworks/${lib} + install_name_tool -change ${LIB_DIR}/liblcms.1.dylib @executable_path/../Frameworks/liblcms.1.dylib Contents/Frameworks/${lib} + install_name_tool -change ${LIB_DIR}/liblzma.5.dylib @executable_path/../Frameworks/liblzma.5.dylib Contents/Frameworks/${lib} + install_name_tool -change ${LIB_DIR}/libz.1.dylib @executable_path/../Frameworks/libz.1.dylib Contents/Frameworks/${lib} +done + +# this test should stay at the end of this script +# it checks that all shipped dylibs don't contain references to e.g. ${LIB_PREFIX} +HITS=$(find . -name "*.dylib" | xargs otool -L | grep ${LIB_DIR}) +if [ $? == 0 ]; then + echo "WARNING: references to local libs in included libraries..."; + echo ${HITS}; +fi diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 5a0c3ad..ef529e1 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -80,21 +80,22 @@ if (APPLE) WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) - # find out the location of libqcocoa.dylib + # find out the location of qt5 plugins # current paths include: location via MacPort installation - # TODO: add more possible paths - set(libqcocoa_search_path - /opt/local/share/qt5/plugins/platforms # MacPorts - /usr/local/share/qt5/plugins/platforms # Homebrew (unverified) + # TODO: add more possible paths + allow for envrionment variable to override + set(plugins_search_path + /opt/local/share/qt5/ # MacPorts + /usr/local/share/qt5/ # Homebrew (unverified) ) - find_library(LIBCOCOA NAMES libqcocoa.dylib PATHS ${libqcocoa_search_path}) - if(NOT LIBCOCOA) - message(FATAL_ERROR "libqcocoa.dylib is required to create an App Bundle!") + find_path(QT5SHARE NAMES plugins PATHS ${plugins_search_path}) + if(NOT QT5SHARE) + message(FATAL_ERROR "Could not determine qt5/plugins base directory.") endif() + set(QT5PLUGINS "${QT5SHARE}/plugins") # find out the location of the Frameworks # current paths include: location via MacPort installation - # TODO: add more possible paths + # TODO: add more possible paths + allow for envrionment variable to override set(frameworks_search_path /opt/local/Library/Frameworks # MacPorts /usr/local/Library/Frameworks # Homebrew (unverified) @@ -109,7 +110,7 @@ if (APPLE) add_custom_command( TARGET ${BINARY_NAME} POST_BUILD - COMMAND ../../scripts/fix-plugins.sh ${LIBCOCOA} ${FRAMEWORKS} + COMMAND ../../scripts/fix-plugins.sh ${QT5PLUGINS} ${FRAMEWORKS} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${BINARY_NAME}.app )