Skip to content
Permalink
Browse files

Mac packaging updates

  • Loading branch information
William Kyngesburye
William Kyngesburye committed Mar 24, 2018
1 parent 20c071b commit bf8b1e90dac7a27d7e7dca013eb64dc6c39e658d
Showing with 88 additions and 35 deletions.
  1. +4 −0 mac/cmake/0vars.cmake.in
  2. +84 −35 mac/cmake/1qt.cmake.in
@@ -13,6 +13,10 @@ SET (CMAKE_VERBOSE_MAKEFILE "@CMAKE_VERBOSE_MAKEFILE@")
SET (CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
SET (CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@")

# Qt5 cmake does not create overall qt prefix var, only individual lib prefixes.
# For simplicity, assume core prefix same as all others
SET (QT_LIBRARY_DIR "@_qt5Core_install_prefix@/lib")

# OS X options
SET (CMAKE_OSX_ARCHITECTURES "@CMAKE_OSX_ARCHITECTURES@")
SET (OSX_HAVE_LOADERPATH @OSX_HAVE_LOADERPATH@)
@@ -11,17 +11,33 @@ INCLUDE ("@CMAKE_SOURCE_DIR@/cmake/MacBundleMacros.cmake")
INCLUDE ("@CMAKE_SOURCE_DIR@/cmake/QCAMacros.cmake")

# Qt framework version is major version
SET (QT_FWVER @QT_VERSION_MAJOR@)
SET (QT_FWVER "5")

# build list of Qt frameworks to bundle

# core list, includes dependencies and used by extra plugins
SET (QTLISTQG QtCore QtGui phonon QtXml QtNetwork QtSvg QtSql QtWebKit QtXmlPatterns QtDBus QtMultimedia QtOpenGL QtTest)
SET (PYQTLIST Qt QtCore QtGui phonon QtXml QtNetwork QtSvg QtSql QtWebKit QtXmlPatterns QtDBus QtMultimedia QtOpenGL QtTest)
SET (QTLISTQG QtCore QtGui QtWidgets QtNetwork QtXml QtSvg QtConcurrent QtPrintSupport QtPositioning QtTest QtSql)
SET (PYQTLIST Qt QtCore QtGui QtWidgets QtNetwork QtXml QtSvg QtPrintSupport QtPositioning QtTest QtSql)

IF(@WITH_QTWEBKIT@)
SET (QTLISTQG ${QTLISTQG} QtWebKit QtWebKitWidgets QtSensors QtQuick QtQml QtWebChannel QtMultimedia QtMultimediaWidgets QtOpenGL)
SET (PYQTLIST ${PYQTLIST} QtWebKit QtWebKitWidgets QtSensors QtQuick QtQml QtWebChannel QtMultimedia QtMultimediaWidgets QtOpenGL)
ENDIF ()

IF(@WITH_3D@)
SET (QTLISTQG ${QTLISTQG} Qt3DCore Qt3DRender Qt3DInput Qt3DLogic Qt3DExtras QtGamepad)
SET (PYQTLIST ${PYQTLIST} Qt3DCore Qt3DRender Qt3DInput Qt3DLogic Qt3DExtras QtGamepad)
ENDIF ()

IF(@WITH_GLOBE@)
SET (QTLISTQG ${QTLISTQG} QtOpenGL)
SET (PYQTLIST ${PYQTLIST} QtOpenGL)
ENDIF ()

# add Qsci.so, if available
IF (@QSCI_FOUND@)
SET (PYQTLIST ${PYQTLIST} Qsci)
SET (QTLISTQG ${QTLISTQG} QtMacExtras)
SET (PYQTLIST ${PYQTLIST} Qsci QtMacExtras)
ENDIF (@QSCI_FOUND@)

MYMESSAGE ("Qt list: ${QTLISTQG}")
@@ -30,21 +46,23 @@ MYMESSAGE ("Qt list: ${QTLISTQG}")

IF (NOT @OSX_HAVE_LOADERPATH@)
EXECUTE_PROCESS (COMMAND ln -sfn ../Frameworks "${QAPPDIR}/")
IF (IS_DIRECTORY "${QLIBXIR}/grass/bin")
EXECUTE_PROCESS (COMMAND ln -sfn ../@QGIS_LIBEXEC_SUBDIR_REV@/@QGIS_FW_SUBDIR@ "${QLIBXDIR}/grass/Frameworks")
IF (IS_DIRECTORY "${QLIBDIR}/grass/bin")
EXECUTE_PROCESS (COMMAND ln -sfn ../@QGIS_LIBEXEC_SUBDIR_REV@/@QGIS_FW_SUBDIR@ "${QLIBDIR}/grass/Frameworks")
ENDIF ()
EXECUTE_PROCESS (COMMAND ln -sfn @QGIS_CGIBIN_SUBDIR_REV@/@QGIS_LIB_SUBDIR@ "${QCGIDIR}/lib")
ENDIF (NOT @OSX_HAVE_LOADERPATH@)

### copy files

# Qt frameworks
# Qt5 cmake does not create overall qt prefix var, only individual lib prefixes.
# For simplicity, assume core prefix same as all others.

MESSAGE (STATUS "Copying Qt frameworks...")
EXECUTE_PROCESS (COMMAND mkdir -p "${QFWDIR}")
FOREACH (QFW ${QTLISTQG})
IF (NOT IS_DIRECTORY "${QFWDIR}/${QFW}.framework")
COPY_FRAMEWORK("@QT_LIBRARY_DIR@" ${QFW} "${QFWDIR}")
COPY_FRAMEWORK("${QT_LIBRARY_DIR}" ${QFW} "${QFWDIR}")
ENDIF ()
ENDFOREACH (QFW)

@@ -56,10 +74,10 @@ FOREACH (QI qgif;qico;qjpeg;qsvg;qtiff)
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QT_PLUGINS_DIR@/imageformats/lib${QI}.dylib" "${QPLUGDIR}/../imageformats/lib${QI}.dylib")
ENDIF ()
ENDFOREACH (QI)
EXECUTE_PROCESS (COMMAND mkdir -p "${QPLUGDIR}/../codecs")
FOREACH (QTC cn;jp;kr;tw)
IF (NOT EXISTS "${QPLUGDIR}/../codecs/libq${QTC}codecs.dylib")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QT_PLUGINS_DIR@/codecs/libq${QTC}codecs.dylib" "${QPLUGDIR}/../codecs/libq${QTC}codecs.dylib")
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")
ENDIF ()
ENDFOREACH (QTC)
EXECUTE_PROCESS (COMMAND mkdir -p "${QPLUGDIR}/../sqldrivers")
@@ -83,10 +101,6 @@ 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")
ENDIF ()
EXECUTE_PROCESS (COMMAND mkdir -p "${QPLUGDIR}/../phonon_backend")
IF (NOT EXISTS "${QPLUGDIR}/../phonon_backend/libphonon_qt7.dylib")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QT_PLUGINS_DIR@/phonon_backend/libphonon_qt7.dylib" "${QPLUGDIR}/../phonon_backend/libphonon_qt7.dylib")
ENDIF ()

# Qwt

@@ -166,7 +180,7 @@ ENDIF (@WITH_QWTPOLAR@ AND NOT @WITH_INTERNAL_QWTPOLAR@)
# QCA

STRING (REGEX MATCH "\\.dylib$" ISLIB "@QCA_LIBRARY@")
STRING (REGEX MATCH "qca.framework" ISFW "@QCA_LIBRARY@")
STRING (REGEX MATCH "qca.*.framework" ISFW "@QCA_LIBRARY@")
IF (ISLIB)
# shared libraries
MESSAGE (STATUS "Copying QCA and updating library paths...")
@@ -182,18 +196,24 @@ ELSEIF (ISFW AND EXISTS "@QCA_LIBRARY@")
# framework
MESSAGE (STATUS "Copying QCA framework and updating library paths...")
SET (QCA_LIBRARY "@QCA_LIBRARY@")
STRING (REGEX MATCH "qca.framework/qca" _has_bin "${QCA_LIBRARY}")
STRING (REGEX MATCH "qca-qt5" _has_long_name "${QCA_LIBRARY}")
IF (_has_long_name)
SET (_qca_libname "qca-qt5")
ELSE ()
SET (_qca_libname "qca")
ENDIF ()
STRING (REGEX MATCH "${_qca_libname}.framework/${_qca_libname}" _has_bin "${QCA_LIBRARY}")
IF (NOT _has_bin)
SET (QCA_LIBRARY "${QCA_LIBRARY}/qca")
SET (QCA_LIBRARY "${QCA_LIBRARY}/${_qca_libname}")
ENDIF ()
SET (QCA_CHG_TO "${ATLOADER}/@QGIS_PLUGIN_SUBDIR_REV@/${QGIS_FW_SUBDIR}/qca.framework/qca")
IF (NOT IS_DIRECTORY "${QFWDIR}/qca.framework")
STRING(REGEX REPLACE "/qca.framework.*" "" QCA_PARENT "@QCA_LIBRARY@")
COPY_FRAMEWORK("${QCA_PARENT}" "qca" "${QFWDIR}")
SET (QCA_CHG_TO "${ATLOADER}/@QGIS_PLUGIN_SUBDIR_REV@/${QGIS_FW_SUBDIR}/${_qca_libname}.framework/${_qca_libname}")
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}")
ENDIF ()
GET_INSTALL_NAME ("${QCA_LIBRARY}" "qca" QCA_CHG)
GET_INSTALL_NAME ("${QCA_LIBRARY}" "${_qca_libname}" QCA_CHG)
IF (QCA_CHG)
UPDATEQGISPATHS (${QCA_CHG} qca)
UPDATEQGISPATHS (${QCA_CHG} ${_qca_libname})
ENDIF ()
ENDIF ()
# copy and relink the plugins
@@ -231,6 +251,17 @@ IF (@QSCINTILLA_LIBRARY@ MATCHES ".*libqscintilla2.dylib")
ENDIF (QSCI_CHG)
ENDIF ()

# QtKeychain

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")
GET_INSTALL_NAME ("@QTKEYCHAIN_LIBRARY@" "libqt5keychain" QTKEY_CHG)
IF (QTKEY_CHG)
UPDATEQGISPATHS (${QTKEY_CHG} libqt5keychain.dylib)
ENDIF (QTKEY_CHG)
ENDIF ()

# Tell user what Python paths are being searched for modules and packages
# see: PYTHON_MODULE_PATHS in 0vars.cmake.in for why not all PyQt-related modules
# can be assumed to exist in symlinked-resolved PyQt or sip module directories
@@ -257,6 +288,7 @@ MESSAGE (STATUS "Copying PyQt...")
EXECUTE_PROCESS (COMMAND mkdir -p "${QGISPYDIR}/PyQt${QT_FWVER}")
FOREACH (PQ ${PYQTLIST})
SET (MODNAME "${PQ}.so")
SET (MODPYI "PyQt${QT_FWVER}/${PQ}.pyi")
SET (MODSUBPATH "PyQt${QT_FWVER}/${MODNAME}")
# search for each module separately, instead of only in first found PyQt directory, since PyQt may
# be installed to its a specific prefix, like with Homebrew, then symlinked into common 'site-packages'
@@ -265,28 +297,31 @@ FOREACH (PQ ${PYQTLIST})
IF (NOT EXISTS "${QGISPYDIR}/${MODSUBPATH}")
# MESSAGE (STATUS "ditto ${QARCHS} \"${PYQT5MOD}\" \"${QGISPYDIR}/${MODSUBPATH}\"")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "${MODDIR}/${MODSUBPATH}" "${QGISPYDIR}/${MODSUBPATH}")
IF (EXISTS "${MODDIR}/${MODPYI}")
EXECUTE_PROCESS (COMMAND ditto "${MODDIR}/${MODPYI}" "${QGISPYDIR}/${MODPYI}")
ENDIF ()
ENDIF ()
ELSE (MODDIR)
MESSAGE (STATUS " PyQt5 module ${MODNAME} not found")
ENDIF (MODDIR)
UNSET(PYQT5MOD)
ENDFOREACH (PQ)
PYTHONMODULEDIR("PyQt${QT_FWVER}" PYQTMODDIR)
FILE (GLOB PQPYLIST "${PYQTMODDIR}/PyQt${QT_FWVER}/*.py")
FILE (GLOB PQPYLIST "${PYQTMODDIR}/PyQt${QT_FWVER}/*.py*")
FOREACH (PQPY ${PQPYLIST})
EXECUTE_PROCESS (COMMAND cp -fp "${PQPY}" "${QGISPYDIR}/PyQt${QT_FWVER}/")
ENDFOREACH (PQPY)
EXECUTE_PROCESS (COMMAND cp -RfpL "${PYQTMODDIR}/PyQt${QT_FWVER}/uic" "${QGISPYDIR}/PyQt${QT_FWVER}")

# PyQt utilities

FOREACH (PU pylupdate4;pyrcc4)
FOREACH (PU pylupdate5;pyrcc5)
IF (NOT EXISTS "${QBINDIR}/${PU}")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@PYQT5_BIN_DIR@/${PU}" "${QBINDIR}/")
ENDIF ()
ENDFOREACH (PU)
IF (NOT EXISTS "${QBINDIR}/pyuic4")
EXECUTE_PROCESS (COMMAND sed -E "s, /.*/PyQt5/uic/pyuic.py, \"\$(/usr/bin/dirname \"\$0\")/../../Resources/python/PyQt5/uic/pyuic.py\"," "@PYQT5_BIN_DIR@/pyuic4"
IF (NOT EXISTS "${QBINDIR}/pyuic5")
EXECUTE_PROCESS (COMMAND sed -E "s, /.*/PyQt5/uic/pyuic.py, \"\$(/usr/bin/dirname \"\$0\")/../../Resources/python/PyQt5/uic/pyuic.py\"," "@PYQT5_BIN_DIR@/pyuic5"
OUTPUT_VARIABLE PYUIC_CONTENTS)
FILE (WRITE "${QBINDIR}/pyuic4" "${PYUIC_CONTENTS}")
EXECUTE_PROCESS (COMMAND chmod +x "${QBINDIR}/pyuic4")
@@ -346,7 +381,7 @@ MESSAGE (STATUS "Updating Qt library paths...")
FOREACH (QFW ${QTLISTQG})
# get install names from installed in case bundled copy already changed
# from a previous install attempt
GET_INSTALL_NAME ("@QT_LIBRARY_DIR@/${QFW}.framework/${QFW}" ${QFW}.framework QQ)
GET_INSTALL_NAME ("${QT_LIBRARY_DIR}/${QFW}.framework/${QFW}" ${QFW}.framework QQ)
SET (QFW_CHG "${QQ}")
# qgis stuff
UPDATEQGISPATHS ("${QFW_CHG}" ${QFW})
@@ -366,6 +401,20 @@ FOREACH (QFW ${QTLISTQG})
ENDIF ()
INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QFWDIR}/qwt.framework/qwt")
ENDIF (ISLIB)
# qtkeychain
STRING (REGEX MATCH "\\.dylib$" ISLIB "@QTKEYCHAIN_LIBRARY@")
STRING (REGEX MATCH "qt5keychain.framework" ISFW "@QTKEYCHAIN_LIBRARY@")
IF (ISLIB)
IF (@OSX_HAVE_LOADERPATH@)
SET (QFW_CHG_TO "${ATLOADER}/${QGIS_LIB_SUBDIR_REV}/${QGIS_FW_SUBDIR}/${LIBPOST}")
ENDIF ()
INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QLIBDIR}/libqt5keychain.dylib")
ELSEIF (ISFW AND EXISTS "${QFWDIR}/qt5keychain.framework/qt5keychain")
IF (@OSX_HAVE_LOADERPATH@)
SET (QFW_CHG_TO "${ATLOADER}/../../../${LIBPOST}")
ENDIF ()
INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QFWDIR}/qt5keychain.framework/qt5keychain")
ENDIF (ISLIB)
# QwtPolar
STRING (REGEX MATCH "\\.dylib$" ISLIB "@QWTPOLAR_LIBRARY@")
STRING (REGEX MATCH "qwtpolar.framework" ISFW "@QWTPOLAR_LIBRARY@")
@@ -382,17 +431,17 @@ FOREACH (QFW ${QTLISTQG})
ENDIF (ISLIB)
# QCA
STRING (REGEX MATCH "\\.dylib$" ISLIB "@QCA_LIBRARY@")
STRING (REGEX MATCH "qca.framework" ISFW "@QCA_LIBRARY@")
STRING (REGEX MATCH "${_qca_libname}.framework" ISFW "@QCA_LIBRARY@")
IF (ISLIB)
IF (@OSX_HAVE_LOADERPATH@)
SET (QFW_CHG_TO "${ATLOADER}/${QGIS_LIB_SUBDIR_REV}/${QGIS_FW_SUBDIR}/${LIBPOST}")
ENDIF ()
INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QLIBDIR}/libqca.dylib")
ELSEIF (ISFW AND EXISTS "${QFWDIR}/qca.framework/qca")
ELSEIF (ISFW AND EXISTS "${QFWDIR}/${_qca_libname}.framework/${_qca_libname}")
IF (@OSX_HAVE_LOADERPATH@)
SET (QFW_CHG_TO "${ATLOADER}/../../../${LIBPOST}")
ENDIF ()
INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QFWDIR}/qca.framework/qca")
INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QFWDIR}/${_qca_libname}.framework/${_qca_libname}")
ENDIF (ISLIB)
# osgEarthQt
IF (@HAVE_OSGEARTHQT@)
@@ -423,9 +472,9 @@ FOREACH (QFW ${QTLISTQG})
FOREACH (QI qgif;qico;qjpeg;qsvg;qtiff)
INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QPLUGDIR}/../imageformats/lib${QI}.dylib")
ENDFOREACH (QI)
FOREACH (QC cn;jp;kr;tw)
INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QPLUGDIR}/../codecs/libq${QC}codecs.dylib")
ENDFOREACH (QC)
FOREACH (QP cocoa;minimal;offscreen)
INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QPLUGDIR}/../platforms/libq${QP}.dylib")
ENDFOREACH (QP)
FOREACH (QSL ${QTLISTSQL})
IF (EXISTS "${QPLUGDIR}/../sqldrivers/libqsql${QSL}.dylib")
INSTALLNAMETOOL_CHANGE ("${QFW_CHG}" "${QFW_CHG_TO}" "${QPLUGDIR}/../sqldrivers/libqsql${QSL}.dylib")

0 comments on commit bf8b1e9

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