Skip to content
Permalink
Browse files

simplify framework bundling, don't need to know fw version (always cu…

…rrent)
  • Loading branch information
kyngchaos committed Jul 24, 2011
1 parent 6d85c9a commit 932f511c03b48a7a6d0f3226e04779a9453cb20f
Showing with 46 additions and 29 deletions.
  1. +40 −8 cmake/MacBundleMacros.cmake
  2. +6 −21 mac/cmake/1qt.cmake.in
@@ -10,18 +10,50 @@
# regex stuff taken from GetPrerequisites

FUNCTION (GET_INSTALL_NAME LIBFILE LIBNAME OUTVAR)
EXECUTE_PROCESS (COMMAND otool -L "${LIBFILE}" OUTPUT_VARIABLE iname_out)
# remove 1st line, it's just path to lib file
STRING (REGEX REPLACE ".*:\n" "" iname "${iname_out}")
IF (iname)
# find libname
STRING (REGEX MATCH "[^\n\t ]*${LIBNAME}[^\n ]*" iname "${iname}")
ENDIF (iname)
EXECUTE_PROCESS (COMMAND otool -L "${LIBFILE}" OUTPUT_VARIABLE iname_out)
# remove 1st line, it's just path to lib file
STRING (REGEX REPLACE ".*:\n" "" iname "${iname_out}")
IF (iname)
# find libname
STRING (REGEX MATCH "[^\n\t ]*${LIBNAME}[^\n ]*" iname "${iname}")
ENDIF (iname)
SET (${OUTVAR} ${iname} PARENT_SCOPE)
ENDFUNCTION (GET_INSTALL_NAME)

# install_name_tool -change CHANGE CHANGETO CHANGEBIN

FUNCTION (INSTALLNAMETOOL_CHANGE CHANGE CHANGETO CHANGEBIN)
EXECUTE_PROCESS (COMMAND install_name_tool -change ${CHANGE} ${CHANGETO} "${CHANGEBIN}")
EXECUTE_PROCESS (COMMAND install_name_tool -change ${CHANGE} ${CHANGETO} "${CHANGEBIN}")
ENDFUNCTION (INSTALLNAMETOOL_CHANGE)

# copy a framework, only specified archs, current version
# pass CMAKE_BUILD_TYPE to FWDEBUG
FUNCTION (COPY_FRAMEWORK FWPREFIX FWNAME FWARCHS FWDEBUG FWDEST)
# reconstruct framework to avoid excessive copying, then deleting
# especially when debug variants are present
# find current version
# use python because pwd not working with WORKING_DIRECTORY param
EXECUTE_PROCESS (
COMMAND python -c "import os.path\nprint os.path.realpath(\"${FWPREFIX}/${FWNAME}.framework/Versions/Current\")"
OUTPUT_VARIABLE FWDIRPHYS
)
STRING (STRIP "${FWDIRPHYS}" FWDIRPHYS)
STRING (REGEX MATCH "[^/\n]+$" FWVER "${FWDIRPHYS}")
EXECUTE_PROCESS (COMMAND mkdir -p "${FWDEST}/${FWNAME}.framework/Versions/${FWVER}")
EXECUTE_PROCESS (COMMAND ln -sfh ${FWVER} "${FWDEST}/${FWNAME}.framework/Versions/Current")
EXECUTE_PROCESS (COMMAND ditto ${FWARCHS} "${FWPREFIX}/${FWNAME}.framework/Versions/${FWVER}/${FWNAME}" "${FWDEST}/${FWNAME}.framework/Versions/${FWVER}/${FWNAME}")
EXECUTE_PROCESS (COMMAND ln -sf Versions/Current/${FWNAME} "${FWDEST}/${FWNAME}.framework/${FWNAME}")
IF (IS_DIRECTORY "${FWPREFIX}/${FWNAME}.framework/Versions/${FWVER}/Resources")
EXECUTE_PROCESS (COMMAND cp -Rfp "${FWPREFIX}/${FWNAME}.framework/Versions/${FWVER}/Resources" "${FWDEST}/${FWNAME}.framework/Versions/${FWVER}")
EXECUTE_PROCESS (COMMAND ln -sfh Versions/Current/Resources "${FWDEST}/${FWNAME}.framework/Resources")
ENDIF (IS_DIRECTORY "${FWPREFIX}/${FWNAME}.framework/Versions/${FWVER}/Resources")
# debug variants
SET (FWD "${FWNAME}_debug")
IF ("${FWDEBUG}" STREQUAL "Debug" AND EXISTS "${FWPREFIX}/${FWNAME}.framework/Versions/${FWVER}/${FWD}")
EXECUTE_PROCESS (COMMAND ditto ${FWARCHS} "${FWPREFIX}/${FWNAME}.framework/Versions/${FWVER}/${FWD}" "${FWDEST}/${FWNAME}.framework/Versions/${FWVER}/${FWD}")
EXECUTE_PROCESS (COMMAND ln -sf Versions/Current/${FWD} "${FWDEST}/${FWNAME}.framework/${FWD}")
IF (IS_DIRECTORY "${FWPREFIX}/${FWNAME}.framework/${FWD}.dSYM")
EXECUTE_PROCESS (COMMAND ditto -X ${FWARCHS} "${FWPREFIX}/${FWNAME}.framework/${FWD}.dSYM" "${FWDEST}/${FWNAME}.framework")
ENDIF ()
ENDIF ()
ENDFUNCTION (COPY_FRAMEWORK)
@@ -69,9 +69,13 @@ IF (@QT_USE_QTWEBKIT@)
SET (PYQTLIST ${PYQTLIST} QtXmlPatterns)
ENDIF ()
ENDIF (@QT_USE_QTWEBKIT@)
IF (@OSGEARTH_FOUND@)
SET (QTLISTQG ${QTLISTQG} QtOpenGL)
SET (PYQTLIST ${PYQTLIST} QtOpenGL)
ENDIF (@OSGEARTH_FOUND@)
MYMESSAGE ("Qt list: ${QTLISTQG}")

# qt arches
# build arches
FOREACH (QARCH @CMAKE_OSX_ARCHITECTURES@)
SET (QARCHS ${QARCHS} "--arch" "${QARCH}")
ENDFOREACH (QARCH)
@@ -93,26 +97,7 @@ MESSAGE (STATUS "Copying Qt frameworks...")
EXECUTE_PROCESS (COMMAND mkdir -p "${QFWDIR}")
FOREACH (QFW ${QTLISTQG})
IF (NOT IS_DIRECTORY "${QFWDIR}/${QFW}.framework")
# reconstruct framework to avoid excessive copying, then deleting
# especially when debug variants are present
EXECUTE_PROCESS (COMMAND mkdir -p "${QFWDIR}/${QFW}.framework/Versions/${QT_FWVER}")
EXECUTE_PROCESS (COMMAND ln -sfh ${QT_FWVER} "${QFWDIR}/${QFW}.framework/Versions/Current")
MYMESSAGE ("ditto ${QARCHS} \"@QT_LIBRARY_DIR@/${QFW}.framework/Versions/${QT_FWVER}/${QFW}\" \"${QFWDIR}/${QFW}.framework/Versions/${QT_FWVER}/${QFW}\"")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QT_LIBRARY_DIR@/${QFW}.framework/Versions/${QT_FWVER}/${QFW}" "${QFWDIR}/${QFW}.framework/Versions/${QT_FWVER}/${QFW}")
EXECUTE_PROCESS (COMMAND ln -sf Versions/Current/${QFW} "${QFWDIR}/${QFW}.framework/${QFW}")
IF (IS_DIRECTORY "@QT_LIBRARY_DIR@/${QFW}.framework/Versions/${QT_FWVER}/Resources")
EXECUTE_PROCESS (COMMAND cp -Rfp "@QT_LIBRARY_DIR@/${QFW}.framework/Versions/${QT_FWVER}/Resources" "${QFWDIR}/${QFW}.framework/Versions/${QT_FWVER}")
EXECUTE_PROCESS (COMMAND ln -sfh Versions/Current/Resources "${QFWDIR}/${QFW}.framework/Resources")
ENDIF (IS_DIRECTORY "@QT_LIBRARY_DIR@/${QFW}.framework/Versions/${QT_FWVER}/Resources")
# debug variants
SET (QFWD "${QFW}_debug")
IF ("@CMAKE_BUILD_TYPE@" STREQUAL "Debug" AND EXISTS "@QT_LIBRARY_DIR@/${QFW}.framework/Versions/${QT_FWVER}/${QFWD}")
EXECUTE_PROCESS (COMMAND ditto ${QARCHS} "@QT_LIBRARY_DIR@/${QFW}.framework/Versions/${QT_FWVER}/${QFWD}" "${QFWDIR}/${QFW}.framework/Versions/${QT_FWVER}/${QFWD}")
EXECUTE_PROCESS (COMMAND ln -sf Versions/Current/${QFWD} "${QFWDIR}/${QFW}.framework/${QFWD}")
IF (IS_DIRECTORY "@QT_LIBRARY_DIR@/${QFW}.framework/${QFWD}.dSYM")
EXECUTE_PROCESS (COMMAND ditto -X ${QARCHS} "@QT_LIBRARY_DIR@/${QFW}.framework/${QFWD}.dSYM" "${QFWDIR}/${QFW}.framework")
ENDIF ()
ENDIF ()
COPY_FRAMEWORK("@QT_LIBRARY_DIR@" ${QFW} "${QARCHS}" @CMAKE_BUILD_TYPE@ "${QFWDIR}")
ENDIF ()
ENDFOREACH (QFW)

0 comments on commit 932f511

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