Skip to content

Commit

Permalink
Merge becf72a into 7064c62
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Sep 30, 2019
2 parents 7064c62 + becf72a commit c80759a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 61 deletions.
78 changes: 46 additions & 32 deletions CMakeLists.txt
Expand Up @@ -398,44 +398,56 @@ endforeach()

include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/diff_match_patch/src)

# On macOS, keep track of the Qt libraries against which we need to link
# On macOS, keep track of the Qt libraries against which we need to link and
# make sure that we always use their release version
# Note: indeed, from Qt 5.12.5, to build a debug version of a Qt-based
# application implies using the debug version of the Qt libraries, which
# we don't want to do (since it would require us to generate both a
# release and a debug version of our Qt-based third-party libraries)...

if(APPLE)
if(ENABLE_TESTS)
set(QTTEST QtTest)
set(TEST Test)
endif()

if(USE_PREBUILT_QTWEBKIT_PACKAGE)
set(QTWEBKIT QtWebKit)
set(QTWEBKITWIDGETS QtWebKitWidgets)
set(WEBKIT WebKit)
set(WEBKITWIDGETS WebKitWidgets)
endif()

set(MACOS_QT_LIBRARIES
QtConcurrent
QtCore
QtDBus
QtGui
QtHelp
QtMacExtras
QtMultimedia
QtMultimediaWidgets
QtNetwork
QtOpenGL
QtPositioning
QtPrintSupport
QtQml
QtQuick
QtSensors
QtSql
QtSvg
${QTTEST}
QtWebChannel
${QTWEBKIT}
${QTWEBKITWIDGETS}
QtWidgets
QtXml
QtXmlPatterns
Concurrent
Core
DBus
Gui
Help
MacExtras
Multimedia
MultimediaWidgets
Network
OpenGL
Positioning
PrintSupport
Qml
Quick
Sensors
Sql
Svg
${TEST}
WebChannel
${WEBKIT}
${WEBKITWIDGETS}
Widgets
Xml
XmlPatterns
)

foreach(QT_LIBRARY ${MACOS_QT_LIBRARIES})
find_package(Qt5${QT_LIBRARY} REQUIRED)

get_target_property(QT_RELEASE_LIBRARY Qt5::${QT_LIBRARY} IMPORTED_LOCATION_RELEASE)
set_target_properties(Qt5::${QT_LIBRARY} PROPERTIES "IMPORTED_LOCATION_DEBUG" "${QT_RELEASE_LIBRARY}")
endforeach()
endif()

# Some general build settings
Expand Down Expand Up @@ -812,7 +824,7 @@ if(ENABLE_TESTS)
# RPATH rather than RUNPATH on Linux

if(APPLE)
macos_clean_up_file_with_qt_dependencies(${RUNTESTS_NAME} ${DEST_TESTS_DIR} ${MAIN_TEST_FILENAME})
strip_file(${RUNTESTS_NAME} ${DEST_TESTS_DIR}/${MAIN_TEST_FILENAME})
elseif(NOT WIN32)
runpath2rpath(${RUNTESTS_NAME} ${DEST_TESTS_DIR}/${MAIN_TEST_FILENAME})
endif()
Expand Down Expand Up @@ -957,8 +969,10 @@ foreach(PLUGIN ${PLUGINS})
endforeach()

# Fetch parts of our documentation and build it
# Note: we start afresh to make sure that our CI system is always happy...

execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/doc
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/ext/doc
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/doc
${PROJECT_BUILD_DIR}/doc)

configure_file(${PROJECT_BUILD_DIR}/doc/${CMAKE_PROJECT_NAME}.qhcp.in
Expand Down Expand Up @@ -1052,12 +1066,12 @@ if(APPLE)

# Clean up the OpenCOR executable

macos_clean_up_file_with_qt_dependencies(${CMAKE_PROJECT_NAME} ${PROJECT_BUILD_DIR}/${CMAKE_PROJECT_NAME}.app/Contents/MacOS ${CMAKE_PROJECT_NAME})
strip_file(${CMAKE_PROJECT_NAME} ${PROJECT_BUILD_DIR}/${CMAKE_PROJECT_NAME}.app/Contents/MacOS/${CMAKE_PROJECT_NAME})

# Qt libraries required by OpenCOR

foreach(QT_LIBRARY ${MACOS_QT_LIBRARIES})
macos_deploy_qt_library(${QT_LIBRARY})
macos_deploy_qt_library(Qt${QT_LIBRARY})
endforeach()

# Qt plugins required by OpenCOR
Expand Down
36 changes: 7 additions & 29 deletions cmake/common.cmake
Expand Up @@ -267,7 +267,9 @@ macro(add_plugin PLUGIN_NAME)
# Qt modules

foreach(ARG_QT_MODULE ${ARG_QT_MODULES})
find_package(Qt5${ARG_QT_MODULE} REQUIRED)
if(NOT APPLE)
find_package(Qt5${ARG_QT_MODULE} REQUIRED)
endif()

target_link_libraries(${PROJECT_NAME}
Qt5::${ARG_QT_MODULE}
Expand Down Expand Up @@ -352,7 +354,7 @@ macro(add_plugin PLUGIN_NAME)
COMMAND install_name_tool -id @rpath/${ARG_EXTERNAL_BINARY} ${FULL_DEST_EXTERNAL_BINARIES_DIR}/${ARG_EXTERNAL_BINARY})
endif()

macos_clean_up_file_with_qt_dependencies(${COPY_TARGET} ${FULL_DEST_EXTERNAL_BINARIES_DIR} ${ARG_EXTERNAL_BINARY})
strip_file(${COPY_TARGET} ${FULL_DEST_EXTERNAL_BINARIES_DIR}/${ARG_EXTERNAL_BINARY})
endif()

# Package the external library, if needed
Expand Down Expand Up @@ -427,7 +429,7 @@ macro(add_plugin PLUGIN_NAME)
# rather than RUNPATH on Linux

if(APPLE)
macos_clean_up_file_with_qt_dependencies(${PROJECT_NAME} ${DEST_PLUGINS_DIR} ${PLUGIN_FILENAME})
strip_file(${PROJECT_NAME} ${DEST_PLUGINS_DIR}/${PLUGIN_FILENAME})
elseif(NOT WIN32)
runpath2rpath(${PROJECT_NAME} ${PLUGIN_BUILD_DIR}/${PLUGIN_FILENAME})
endif()
Expand Down Expand Up @@ -560,7 +562,7 @@ macro(add_plugin PLUGIN_NAME)
# that it uses RPATH rather than RUNPATH on Linux

if(APPLE)
macos_clean_up_file_with_qt_dependencies(${TEST_NAME} ${DEST_TESTS_DIR} ${TEST_FILENAME})
strip_file(${TEST_NAME} ${DEST_TESTS_DIR}/${TEST_FILENAME})
elseif(NOT WIN32)
runpath2rpath(${TEST_NAME} ${DEST_TESTS_DIR}/${TEST_FILENAME})
endif()
Expand Down Expand Up @@ -769,30 +771,6 @@ endmacro()

#===============================================================================

macro(macos_clean_up_file_with_qt_dependencies PROJECT_TARGET DIRNAME FILENAME)
# Strip the file of all its local symbols

strip_file(${PROJECT_TARGET} ${DIRNAME}/${FILENAME})

# Make sure that the file refers to our embedded copy of the Qt libraries

foreach(MACOS_QT_LIBRARY ${MACOS_QT_LIBRARIES})
set(MACOS_QT_LIBRARY_FILENAME ${MACOS_QT_LIBRARY}.framework/Versions/${QT_VERSION_MAJOR}/${MACOS_QT_LIBRARY})

set(OLD_REFERENCE @rpath/${MACOS_QT_LIBRARY_FILENAME}_debug)
set(NEW_REFERENCE @rpath/${MACOS_QT_LIBRARY_FILENAME})

if("${PROJECT_TARGET}" STREQUAL "DIRECT")
execute_process(COMMAND install_name_tool -change ${OLD_REFERENCE} ${NEW_REFERENCE} ${DIRNAME}/${FILENAME})
else()
add_custom_command(TARGET ${PROJECT_TARGET} POST_BUILD
COMMAND install_name_tool -change ${OLD_REFERENCE} ${NEW_REFERENCE} ${DIRNAME}/${FILENAME})
endif()
endforeach()
endmacro()

#===============================================================================

macro(macos_deploy_qt_file ORIG_DIRNAME DEST_DIRNAME FILENAME)
# Copy the Qt file

Expand All @@ -801,7 +779,7 @@ macro(macos_deploy_qt_file ORIG_DIRNAME DEST_DIRNAME FILENAME)

# Clean up the Qt file

macos_clean_up_file_with_qt_dependencies(DIRECT ${DEST_DIRNAME} ${FILENAME})
strip_file(DIRECT ${DEST_DIRNAME}/${FILENAME})
endmacro()

#===============================================================================
Expand Down

0 comments on commit c80759a

Please sign in to comment.