Skip to content

Commit

Permalink
CMake: use BundleUtilities to fix up Dolphin.app
Browse files Browse the repository at this point in the history
  • Loading branch information
ligfx committed Feb 4, 2017
1 parent 529dc6a commit 38816bf
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 176 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,6 @@ else()
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
# This doesn't play well with the packaging script that doesn't understand @rpath
set(CMAKE_MACOSX_RPATH OFF)

if(NOT OSX_USE_DEFAULT_SEARCH_PATH)
# Hack up the path to prioritize the path to built-in OS libraries to
# increase the chance of not depending on a bunch of copies of them
Expand Down
46 changes: 46 additions & 0 deletions CMakeTests/DolphinPostprocessBundle.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This module can be used in two different ways.
#
# When invoked as `cmake -P DolphinPostprocessBundle.cmake`, it fixes up an
# application folder to be standalone. It bundles all required libraries from
# the system and fixes up library IDs. Any additional shared libraries, like
# plugins, that are found under Contents/MacOS/ will be made standalone as well.
#
# When called with `include(DolphinPostprocessBundle)`, it defines a helper
# function `dolphin_postprocess_bundle` that sets up the command form of the
# module as a post-build step.

if(CMAKE_GENERATOR)
# Being called as include(DolphinPostprocessBundle), so define a helper function.
set(_DOLPHIN_POSTPROCESS_BUNDLE_MODULE_LOCATION "${CMAKE_CURRENT_LIST_FILE}")
function(dolphin_postprocess_bundle target)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -DDOLPHIN_BUNDLE_PATH="$<TARGET_FILE_DIR:${target}>/../.."
-P "${_DOLPHIN_POSTPROCESS_BUNDLE_MODULE_LOCATION}"
)
endfunction()
return()
endif()

get_filename_component(DOLPHIN_BUNDLE_PATH "${DOLPHIN_BUNDLE_PATH}" REALPATH)
message(STATUS "Fixing up application bundle: ${DOLPHIN_BUNDLE_PATH}")

# Make sure to fix up any additional shared libraries (like plugins) that are
# needed.
file(GLOB_RECURSE extra_libs "${DOLPHIN_BUNDLE_PATH}/Contents/MacOS/*.dylib")

# BundleUtilities doesn't support DYLD_FALLBACK_LIBRARY_PATH behavior, which
# makes it sometimes break on libraries that do weird things with @rpath. Specify
# equivalent search directories until https://gitlab.kitware.com/cmake/cmake/issues/16625
# is fixed and in our minimum CMake version.
set(extra_dirs "/usr/local/lib" "/lib" "/usr/lib")

# BundleUtilities is overly verbose, so disable most of its messages
function(message)
if(NOT ARGV MATCHES "^STATUS;")
_message(${ARGV})
endif()
endfunction()

include(BundleUtilities)
set(BU_CHMOD_BUNDLE_ITEMS ON)
fixup_bundle("${DOLPHIN_BUNDLE_PATH}" "${extra_libs}" "${extra_dirs}")
19 changes: 13 additions & 6 deletions Source/Core/DolphinQt2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ if(APPLE)
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
)

# Update library references to make the bundle portable
add_custom_command(TARGET ${DOLPHINQT2_BINARY} POST_BUILD
COMMAND echo "Fixing up application bundle: ${BUNDLE_PATH}"
COMMAND echo ${CMAKE_SOURCE_DIR}/Tools/deploy-mac.py $<TARGET_FILE_DIR:${DOLPHINQT2_BINARY}>/../..
)
# Copy qt.conf into the bundle
target_sources(${DOLPHINQT2_BINARY} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/qt.conf")
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/qt.conf" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)

# Copy Qt plugins into the bundle
get_target_property(qtcocoa_location Qt5::QCocoaIntegrationPlugin LOCATION)
target_sources(${DOLPHINQT2_BINARY} PRIVATE "${qtcocoa_location}")
set_source_files_properties("${qtcocoa_location}" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS/platforms)

# Copy resources in the bundle
# Copy resources into the bundle
file(GLOB_RECURSE resources RELATIVE "${CMAKE_SOURCE_DIR}/Data" "${CMAKE_SOURCE_DIR}/Data/Sys/*")
foreach(res ${resources})
target_sources(${DOLPHINQT2_BINARY} PRIVATE "${CMAKE_SOURCE_DIR}/Data/${res}")
Expand All @@ -64,6 +67,10 @@ if(APPLE)
MACOSX_PACKAGE_LOCATION "Resources/${resdir}")
source_group("Resources" FILES "${CMAKE_SOURCE_DIR}/Data/${res}")
endforeach()

# Update library references to make the bundle portable
include(DolphinPostprocessBundle)
dolphin_postprocess_bundle(${DOLPHINQT2_BINARY})
else()
install(TARGETS ${DOLPHINQT2_BINARY} RUNTIME DESTINATION ${bindir})
endif()
Empty file added Source/Core/DolphinQt2/qt.conf
Empty file.
7 changes: 2 additions & 5 deletions Source/Core/DolphinWX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,8 @@ if(wxWidgets_FOUND)
endforeach()

# Update library references to make the bundle portable
add_custom_command(TARGET ${DOLPHIN_EXE} POST_BUILD
COMMAND echo "Fixing up application bundle: ${BUNDLE_PATH}"
COMMAND ${CMAKE_SOURCE_DIR}/Tools/deploy-mac.py $<TARGET_FILE_DIR:${DOLPHIN_EXE}>/../..
)

include(DolphinPostprocessBundle)
dolphin_postprocess_bundle(${DOLPHIN_EXE})

# Install bundle into systemwide /Applications directory.
install(TARGETS ${DOLPHIN_EXE} DESTINATION /Applications)
Expand Down
162 changes: 0 additions & 162 deletions Tools/deploy-mac.py

This file was deleted.

0 comments on commit 38816bf

Please sign in to comment.