Skip to content
Permalink
Browse files

strip Qt rpath when bundling

  • Loading branch information
kyngchaos authored and nyalldawson committed Mar 10, 2020
1 parent a04bc86 commit daaeeb40fc526ceea10a595c2ff522aa357504ed
Showing with 21 additions and 1 deletion.
  1. +21 −1 mac/cmake/1qt.cmake.in
@@ -56,7 +56,7 @@ IF (NOT @OSX_HAVE_LOADERPATH@)
EXECUTE_PROCESS (COMMAND ln -sfn @QGIS_CGIBIN_SUBDIR_REV@/@QGIS_LIB_SUBDIR@ "${QCGIDIR}/lib")
ENDIF (NOT @OSX_HAVE_LOADERPATH@)

### copy files
### copy files & strip qt rpath

# Qt frameworks
# Qt5 cmake does not create overall qt prefix var, only individual lib prefixes.
@@ -67,6 +67,7 @@ EXECUTE_PROCESS (COMMAND mkdir -p "${QFWDIR}")
FOREACH (QFW ${QTLISTQG})
IF (NOT IS_DIRECTORY "${QFWDIR}/${QFW}.framework")
COPY_FRAMEWORK("${QT_LIBRARY_DIR}" ${QFW} "${QFWDIR}")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QFWDIR}/${QFW}.framework/${QFW}")
ENDIF ()
ENDFOREACH (QFW)

@@ -76,12 +77,14 @@ EXECUTE_PROCESS (COMMAND mkdir -p "${QPLUGDIR}/../imageformats")
FOREACH (QI qgif;qico;qjpeg;qsvg;qtiff)
IF (NOT EXISTS "${QPLUGDIR}/../imageformats/lib${QI}.dylib")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QT_PLUGINS_DIR@/imageformats/lib${QI}.dylib" "${QPLUGDIR}/../imageformats/lib${QI}.dylib")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QPLUGDIR}/../imageformats/lib${QI}.dylib")
ENDIF ()
ENDFOREACH (QI)
EXECUTE_PROCESS (COMMAND mkdir -p "${QPLUGDIR}/../platforms")
FOREACH (QTP cocoa;minimal;offscreen)
IF (NOT EXISTS "${QPLUGDIR}/../platforms/libq${QTP}.dylib")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QT_PLUGINS_DIR@/platforms/libq${QTP}.dylib" "${QPLUGDIR}/../platforms/libq${QTP}.dylib")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QPLUGDIR}/../platforms/libq${QTP}.dylib")
ENDIF ()
ENDFOREACH (QTP)
EXECUTE_PROCESS (COMMAND mkdir -p "${QPLUGDIR}/../sqldrivers")
@@ -91,11 +94,13 @@ IF (@WITH_QSPATIALITE@)
LIST(APPEND QTLISTSQL spatialite)
IF (EXISTS "${QPLUGDIR}/../sqldrivers/libqsqlspatialite.dylib")
EXECUTE_PROCESS (COMMAND ${CMAKE_COMMAND} -E remove "${QPLUGDIR}/../sqldrivers/libqsqlspatialite.dylib")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QPLUGDIR}/../sqldrivers/libqsqlspatialite.dylib")
ENDIF ()
ENDIF ()
FOREACH (QSL ${QTLISTSQL})
IF (NOT EXISTS "${QPLUGDIR}/../sqldrivers/libqsql${QSL}.dylib" AND EXISTS "@QT_PLUGINS_DIR@/sqldrivers/libqsql${QSL}.dylib")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QT_PLUGINS_DIR@/sqldrivers/libqsql${QSL}.dylib" "${QPLUGDIR}/../sqldrivers/libqsql${QSL}.dylib")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QPLUGDIR}/../sqldrivers/libqsql${QSL}.dylib")
ENDIF ()
ENDFOREACH (QSL)
IF (NOT @WITH_QSPATIALITE@ AND EXISTS "${QPLUGDIR}/../sqldrivers/libqsqlspatialite.dylib")
@@ -104,10 +109,12 @@ ENDIF ()
EXECUTE_PROCESS (COMMAND mkdir -p "${QPLUGDIR}/../iconengines")
IF (NOT EXISTS "${QPLUGDIR}/../iconengines/libqsvgicon.dylib")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QT_PLUGINS_DIR@/iconengines/libqsvgicon.dylib" "${QPLUGDIR}/../iconengines/libqsvgicon.dylib")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QPLUGDIR}/../iconengines/libqsvgicon.dylib")
ENDIF ()
EXECUTE_PROCESS (COMMAND mkdir -p "${QPLUGDIR}/../styles")
IF (NOT EXISTS "${QPLUGDIR}/../styles/libqmacstyle.dylib")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QT_PLUGINS_DIR@/styles/libqmacstyle.dylib" "${QPLUGDIR}/../styles/libqmacstyle.dylib")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QPLUGDIR}/../styles/libqmacstyle.dylib")
ENDIF ()

# Qwt
@@ -119,6 +126,7 @@ IF (QWT_ISLIB)
MESSAGE (STATUS "Copying Qwt and updating library paths...")
IF (NOT EXISTS "${QLIBDIR}/libqwt.dylib")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QWT_LIBRARY@" "${QLIBDIR}/libqwt.dylib")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QLIBDIR}/libqwt.dylib")
ENDIF ()
GET_INSTALL_NAME ("@QWT_LIBRARY@" "libqwt" QWT_CHG)
IF (QWT_CHG)
@@ -130,6 +138,7 @@ ELSEIF (QWT_ISFW AND EXISTS "@QWT_LIBRARY@")
STRING(REGEX REPLACE "/qwt.framework.*" "" QWT_PARENT "@QWT_LIBRARY@")
IF (NOT IS_DIRECTORY "${QFWDIR}/qwt.framework")
COPY_FRAMEWORK("${QWT_PARENT}" "qwt" "${QFWDIR}")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QFWDIR}/qwt.framework/qwt")
ENDIF ()
GET_INSTALL_NAME ("${QWT_PARENT}/qwt.framework/qwt" "qwt.framework" QWT_CHG)
IF (QWT_CHG)
@@ -149,6 +158,7 @@ IF (@WITH_DESKTOP@)
MESSAGE (STATUS "Copying QwtPolar and updating library paths...")
IF (NOT EXISTS "${QLIBDIR}/libqwtpolar.dylib")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QWT_LIBRARY@" "${QLIBDIR}/libqwtpolar.dylib")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QLIBDIR}/libqwtpolar.dylib")
ENDIF ()
GET_INSTALL_NAME ("@QWTPOLAR_LIBRARY@" "libqwtpolar" QWTP_CHG)
IF (QWTP_CHG)
@@ -169,6 +179,7 @@ IF (@WITH_DESKTOP@)
STRING(REGEX REPLACE "/qwtpolar.framework.*" "" QWTP_PARENT "@QWTPOLAR_LIBRARY@")
IF (NOT IS_DIRECTORY "${QFWDIR}/qwtpolar.framework")
COPY_FRAMEWORK("${QWTP_PARENT}" "qwtpolar" "${QFWDIR}")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QFWDIR}/qwtpolar.framework/qwtpolar")
ENDIF ()
GET_INSTALL_NAME ("${QWTP_PARENT}/qwtpolar.framework/qwtpolar" "qwtpolar.framework" QWTP_CHG)
IF (QWTP_CHG)
@@ -197,6 +208,7 @@ IF (ISLIB)
SET (QCA_CHG_TO "${ATLOADER}/@QGIS_PLUGIN_SUBDIR_REV@/${QGIS_LIB_SUBDIR}/libqca.dylib")
IF (NOT EXISTS "${QLIBDIR}/libqca.dylib")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QCA_LIBRARY@" "${QLIBDIR}/libqca.dylib")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QLIBDIR}/libqca.dylib")
ENDIF ()
GET_INSTALL_NAME ("@QCA_LIBRARY@" "libqca" QCA_CHG)
IF (QCA_CHG)
@@ -220,6 +232,7 @@ ELSEIF (ISFW AND EXISTS "@QCA_LIBRARY@")
IF (NOT IS_DIRECTORY "${QFWDIR}/${_qca_libname}.framework")
STRING(REGEX REPLACE "/${_qca_libname}.framework.*" "" QCA_PARENT "@QCA_LIBRARY@")
COPY_FRAMEWORK("${QCA_PARENT}" "${_qca_libname}" "${QFWDIR}")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QFWDIR}/${_qca_libname}.framework/${_qca_libname}")
ENDIF ()
GET_INSTALL_NAME ("${QCA_LIBRARY}" "${_qca_libname}" QCA_CHG)
IF (QCA_CHG)
@@ -234,6 +247,7 @@ MESSAGE (STATUS "Updating QCA plugins with QCA library path in ${QCA_PLUGIN_DIR}
SET(QCA_PLUGINS logger ossl softstore)
FOREACH (qca_plugin ${QCA_PLUGINS})
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "${QCA_PLUGIN_DIR}/crypto/libqca-${qca_plugin}.dylib" "${QPLUGDIR}/../crypto/")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QCA_PLUGIN_DIR}/crypto/libqca-${qca_plugin}.dylib")
IF (QCA_CHG)
INSTALLNAMETOOL_CHANGE ("${QCA_CHG}" "${QCA_CHG_TO}" "${QPLUGDIR}/../crypto/libqca-${qca_plugin}.dylib")
ENDIF ()
@@ -243,6 +257,7 @@ ENDFOREACH ()
# linked to qca and qgis_core frameworks (see also 2lib.cmake.in)
IF (@WITH_QSPATIALITE@ AND EXISTS "${QPLUGDIR}/../sqldrivers/libqsqlspatialite.dylib")
# qca.framework
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QPLUGDIR}/../sqldrivers/libqsqlspatialite.dylib")
INSTALLNAMETOOL_CHANGE ("${QCA_CHG}" "${QCA_CHG_TO}" "${QPLUGDIR}/../sqldrivers/libqsqlspatialite.dylib")
# qgis_core.framework
GET_INSTALL_NAME ("@QGIS_OUTPUT_DIRECTORY@/lib/qgis_core.framework/qgis_core" qgis_core.framework QGCORE)
@@ -260,6 +275,7 @@ ENDIF ()
IF (QSCI_LIB)
MESSAGE (STATUS "Copying QScintilla2 library and updating library paths...")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QSCINTILLA_LIBRARY@" "${QLIBDIR}/${QSCI_LIB}.dylib")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QLIBDIR}/${QSCI_LIB}.dylib")
GET_INSTALL_NAME ("@QSCINTILLA_LIBRARY@" "${QSCI_LIB}" QSCI_CHG)
IF (QSCI_CHG)
UPDATEQGISPATHS (${QSCI_CHG} ${QSCI_LIB}.dylib)
@@ -271,6 +287,7 @@ ENDIF ()
IF (@QTKEYCHAIN_LIBRARY@ MATCHES ".*libqt5keychain.dylib")
MESSAGE (STATUS "Copying QtKeychain library and updating library paths...")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QTKEYCHAIN_LIBRARY@" "${QLIBDIR}/libqt5keychain.dylib")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QLIBDIR}/libqt5keychain.dylib")
GET_INSTALL_NAME ("@QTKEYCHAIN_LIBRARY@" "libqt5keychain" QTKEY_CHG)
IF (QTKEY_CHG)
UPDATEQGISPATHS (${QTKEY_CHG} libqt5keychain.dylib)
@@ -294,8 +311,10 @@ IF (SIPMODDIR)
# MYMESSAGE ("ditto ${QARCHS} \"${SIPMODDIR}/sip.so\" \"${QGISPYDIR}/\"")
IF (${SIPMODDIR} MATCHES ".*PyQt5.*")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "${SIPMODDIR}/sip.so" "${QGISPYDIR}/PyQt5/")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QGISPYDIR}/PyQt5/sip.so")
ELSE ()
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "${SIPMODDIR}/sip.so" "${QGISPYDIR}/")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QGISPYDIR}/sip.so")
ENDIF ()
EXECUTE_PROCESS (COMMAND cp -fp "${SIPMODDIR}/sipconfig.py" "${QGISPYDIR}/")
ENDIF ()
@@ -316,6 +335,7 @@ FOREACH (PQ ${PYQTLIST})
IF (NOT EXISTS "${QGISPYDIR}/${MODSUBPATH}")
# MESSAGE (STATUS "ditto ${QARCHS} \"${PYQT5MOD}\" \"${QGISPYDIR}/${MODSUBPATH}\"")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "${MODDIR}/${MODSUBPATH}" "${QGISPYDIR}/${MODSUBPATH}")
EXECUTE_PROCESS (COMMAND install_name_tool -delete_rpath "@QT_LIBRARY_DIR@" "${QGISPYDIR}/${MODSUBPATH}")
IF (EXISTS "${MODDIR}/${MODPYI}")
EXECUTE_PROCESS (COMMAND ditto "${MODDIR}/${MODPYI}" "${QGISPYDIR}/${MODPYI}")
ENDIF ()

0 comments on commit daaeeb4

Please sign in to comment.
You can’t perform that action at this time.