Skip to content

Commit

Permalink
CMake|macOS: Added a build option to disable Qt deployment
Browse files Browse the repository at this point in the history
It makes debug builds faster when macdeployqt is not run.
Instead, use @rpath to locate the local Qt frameworks.
  • Loading branch information
skyjake committed Apr 7, 2017
1 parent 52756d6 commit 826ce6a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
23 changes: 15 additions & 8 deletions doomsday/apps/plugins/PluginConfig.cmake
Expand Up @@ -37,12 +37,17 @@ macro (deng_add_plugin target)
set_property (TARGET ${target}
APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-braces
)
set (_extraRPath)
if (NOT DENG_ENABLE_DEPLOYQT)
set (_extraRPath ${QT_LIBS})
endif ()
set_target_properties (${target} PROPERTIES
BUNDLE ON
MACOSX_BUNDLE_INFO_PLIST ${DENG_SOURCE_DIR}/cmake/MacOSXPluginBundleInfo.plist.in
BUILD_WITH_INSTALL_RPATH ON # staging prevents CMake's own rpath fixing
INSTALL_RPATH "@executable_path/../Frameworks"
INSTALL_RPATH "@executable_path/../Frameworks;${_extraRPath}"
)
set (_extraRPath)
macx_set_bundle_name ("net.dengine.plugin.${target}")
set (MACOSX_BUNDLE_BUNDLE_EXECUTABLE "${target}.bundle/Contents/MacOS/${target}")
# Stage plugins for symlinking/copying into the client app later.
Expand All @@ -57,13 +62,15 @@ macro (deng_add_plugin target)
"${stage}/${target}.bundle"
)
# Fix the Qt framework install names manually.
deng_bundle_install_names (${target}
SCRIPT_NAME "qtlibs"
LD_PATH "@executable_path/../Frameworks"
QtCore.framework/Versions/5/QtCore
QtNetwork.framework/Versions/5/QtNetwork
VERBATIM
)
if (DENG_ENABLE_DEPLOYQT)
deng_bundle_install_names (${target}
SCRIPT_NAME "qtlibs"
LD_PATH "@executable_path/../Frameworks"
QtCore.framework/Versions/5/QtCore
QtNetwork.framework/Versions/5/QtNetwork
VERBATIM
)
endif ()
deng_xcode_attribs (${target})
deng_bundle_resources ()
else ()
Expand Down
15 changes: 11 additions & 4 deletions doomsday/cmake/Macros.cmake
Expand Up @@ -112,17 +112,21 @@ endmacro (deng_cotire)

macro (deng_target_rpath target)
if (APPLE)
set (_extraRPath)
if (NOT DENG_ENABLE_DEPLOYQT)
# Not deployed; include the local Qt library path in @rpath.
set (_extraRPath "${QT_LIBS}")
endif ()
set_target_properties (${target} PROPERTIES
INSTALL_RPATH "@loader_path/../Frameworks;@executable_path/../${DENG_INSTALL_LIB_DIR}"
INSTALL_RPATH "@loader_path/../Frameworks;@executable_path/../${DENG_INSTALL_LIB_DIR};${_extraRPath}"
)
if (${target} MATCHES "test_.*")
# These won't be deployed, so we can use the full path.
qmake_query (_qtLibPath QT_INSTALL_LIBS)
set_property (TARGET ${target} APPEND PROPERTY
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${DENG_INSTALL_LIB_DIR};${CMAKE_INSTALL_PREFIX}/${DENG_INSTALL_PLUGIN_DIR};${_qtLibPath}"
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${DENG_INSTALL_LIB_DIR};${CMAKE_INSTALL_PREFIX}/${DENG_INSTALL_PLUGIN_DIR};${QT_LIBS}"
)
set (_qtLibPath)
endif ()
set (_extraRPath)
elseif (UNIX)
set_property (TARGET ${target}
PROPERTY INSTALL_RPATH
Expand Down Expand Up @@ -670,6 +674,9 @@ endfunction (deng_install_bundle_deps)
# Run the Qt deploy utility on the target, resolving any local system
# dependencies.
function (deng_install_deployqt target)
if (NOT DENG_ENABLE_DEPLOYQT)
return ()
endif ()
if (UNIX AND NOT APPLE)
return () # No need to deploy Qt.
endif ()
Expand Down
11 changes: 6 additions & 5 deletions doomsday/cmake/Options.cmake
@@ -1,5 +1,5 @@
# Source merging by default is enabled only for debug builds, or never with
# multiconfiguration projects because all configurations must use the
# multiconfiguration projects because all configurations must use the
# same set of source files.
if (MSVC OR XCODE_VERSION)
set (DENG_ENABLE_TURBO_DEFAULT OFF) # multiconfiguration projects
Expand All @@ -11,11 +11,12 @@ else ()
endif ()
endif ()

option (DENG_ENABLE_TURBO "Enable/disable Turbo mode (source merging)"
option (DENG_ENABLE_TURBO "Enable/disable Turbo mode (source merging)"
${DENG_ENABLE_TURBO_DEFAULT})
option (DENG_ENABLE_GUI "Enable/disable the client and all GUI related functionality" ON)
option (DENG_ENABLE_SDK "Enable/disable installation of the Doomsday 2 SDK" ON)
option (DENG_ENABLE_TOOLS "Compile the Doomsday tools" ON)
option (DENG_ENABLE_GUI "Enable/disable the client and all GUI related functionality" ON)
option (DENG_ENABLE_SDK "Enable/disable installation of the Doomsday 2 SDK" ON)
option (DENG_ENABLE_TOOLS "Compile the Doomsday tools" ON)
option (DENG_ENABLE_DEPLOYQT "Enable/disable the *deployqt tool" ON)

if (CCACHE_FOUND OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# GCC seems to have trouble with cotire when using C++11.
Expand Down

0 comments on commit 826ce6a

Please sign in to comment.