Skip to content

Commit

Permalink
CMake|OS X: Building and running with Xcode
Browse files Browse the repository at this point in the history
Like MSVS, Xcode uses different folders for the Debug and Release
binaries. The INTDIR or $<TARGET_FILE> is now used when fixing
dynamic linker install names.
  • Loading branch information
skyjake committed Feb 24, 2015
1 parent df45454 commit 70da41c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doomsday/apps/plugins/PluginConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ macro (deng_add_plugin target)
add_custom_command (TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${stage}"
COMMAND ${CMAKE_COMMAND} -E create_symlink
"${CMAKE_CURRENT_BINARY_DIR}/${target}.bundle"
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${target}.bundle"
"${stage}/${target}.bundle"
)
# Fix the Qt framework install names manually.
Expand Down
23 changes: 17 additions & 6 deletions doomsday/cmake/Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,17 @@ macro (deng_add_library target)
set (_outName)
# Compiler settings.
deng_target_defaults (${target})
if (APPLE)
set_property (TARGET ${target} PROPERTY BUILD_WITH_INSTALL_RPATH ON)
add_custom_command (TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND}
"-DDENG_SOURCE_DIR=${DENG_SOURCE_DIR}"
"-DCMAKE_INSTALL_NAME_TOOL=${CMAKE_INSTALL_NAME_TOOL}"
"-DBINARY_FILE=$<TARGET_FILE:${target}>"
-P "${DENG_SOURCE_DIR}/cmake/QtInstallNames.cmake"
COMMENT "Fixing Qt install names..."
)
endif ()
target_include_directories (${target} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include/>
Expand Down Expand Up @@ -466,14 +477,14 @@ function (deng_bundle_install_names target)
endif ()
set (scriptName "${CMAKE_CURRENT_BINARY_DIR}/postbuild${_suffix}-${target}.cmake")
# Correct the install names of the dependent libraries.
file (GENERATE OUTPUT "${scriptName}" CONTENT "\
set (CMAKE_MODULE_PATH ${DENG_SOURCE_DIR}/cmake)\n\
set (CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL})\n\
include (Macros)\n\
fix_bundled_install_names (\"${CMAKE_CURRENT_BINARY_DIR}/${target}.bundle/Contents/MacOS/${target}\"\
file (GENERATE OUTPUT "${scriptName}" CONTENT "
set (CMAKE_MODULE_PATH ${DENG_SOURCE_DIR}/cmake)
set (CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL})
include (Macros)
fix_bundled_install_names (\"${CMAKE_CURRENT_BINARY_DIR}/\${INT_DIR}/${target}.bundle/Contents/MacOS/${target}\"
\"${libs}\")\n")
add_custom_command (TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -P "${scriptName}"
COMMAND ${CMAKE_COMMAND} -DINT_DIR=${CMAKE_CFG_INTDIR} -P "${scriptName}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endfunction (deng_bundle_install_names)
Expand Down
15 changes: 15 additions & 0 deletions doomsday/cmake/QtInstallNames.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Required variables:
# - DENG_SOURCE_DIR
# - CMAKE_INSTALL_NAME_TOOL
# - BINARY_FILE

include (${DENG_SOURCE_DIR}/cmake/Macros.cmake)

fix_bundled_install_names ("${BINARY_FILE}"
QtCore.framework/Versions/5/QtCore
QtNetwork.framework/Versions/5/QtNetwork
QtGui.framework/Versions/5/QtGui
QtOpenGL.framework/Versions/5/QtOpenGL
QtWidgets.framework/Versions/5/QtWidgets
VERBATIM
)

0 comments on commit 70da41c

Please sign in to comment.