24 else() |
24 else() |
25 set(SPARKLE_FOUND 0) |
25 set(SPARKLE_FOUND 0) |
26 endif() |
26 endif() |
27 endif() |
27 endif() |
28 |
28 |
29 get_target_property(qmake_executable Qt5::qmake IMPORTED_LOCATION) |
|
30 get_filename_component(qt_bin_dir "${qmake_executable}" DIRECTORY) |
|
31 |
|
32 #remove the ";-framework Cocoa" from the SDL2_LIBRARY variable |
29 #remove the ";-framework Cocoa" from the SDL2_LIBRARY variable |
33 string(REGEX REPLACE "(.*);-.*" "\\1" sdl_library_only "${SDL2_LIBRARY}") |
30 string(REGEX REPLACE "(.*);-.*" "\\1" sdl_library_only "${SDL2_LIBRARY}") |
34 #remove the "libSDLmain.a" from the SDL2_LIBRARY variable |
31 #remove the "libSDLmain.a" from the SDL2_LIBRARY variable |
35 string(REGEX REPLACE ".*;(.*)" "\\1" sdl_library_only "${sdl_library_only}") |
32 string(REGEX REPLACE ".*;(.*)" "\\1" sdl_library_only "${sdl_library_only}") |
36 |
33 |
37 #get the neme of the library (harmelss if it is static) |
34 #get the neme of the library (harmelss if it is static) |
38 string(REGEX REPLACE ".*/(.*)$" "\\1" PNG_LIBNAME "${PNG_LIBRARY}") |
35 string(REGEX REPLACE ".*/(.*)$" "\\1" PNG_LIBNAME "${PNG_LIBRARY}") |
39 string(REGEX REPLACE ".*/(.*)$" "\\1" ZLIB_LIBNAME "${ZLIB_LIBRARY}") |
36 string(REGEX REPLACE ".*/(.*)$" "\\1" ZLIB_LIBNAME "${ZLIB_LIBRARY}") |
40 |
37 |
41 set(frameworks_dir ${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}) |
38 set(frameworks_dir ${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}) |
|
39 |
42 if(${BUILD_ENGINE_LIBRARY}) |
40 if(${BUILD_ENGINE_LIBRARY}) |
43 set(engine_full_path "${frameworks_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}") |
41 set(engine_full_path "${frameworks_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}") |
44 else() |
42 else() |
45 set(engine_full_path "${CMAKE_INSTALL_PREFIX}/hwengine${CMAKE_EXECUTABLE_SUFFIX}") |
43 set(engine_full_path "${CMAKE_INSTALL_PREFIX}/hwengine${CMAKE_EXECUTABLE_SUFFIX}") |
46 endif() |
44 endif() |
47 |
45 |
48 find_program(macdeployqt_executable NAMES macdeployqt PATHS ${qt_bin_dir}) |
46 |
49 if(NOT macdeployqt_executable) |
47 #create the .app bundle using BundleUtilities instead of old macdeployqt |
50 message(FATAL_ERROR "The utility macdeployqt is required to create the bundle (searched: ${qt_bin_dir})") |
48 set(APP_DIR "Hedgewars.app") |
|
49 set(APP_BASE_DIR "${CMAKE_INSTALL_PREFIX}/../") # should be, Hedgewars.app/Contents/MacOS/../ |
|
50 |
|
51 # macro to install qt5 plugins |
|
52 # modified from https://github.com/Kitware/CMake/blob/master/Source/QtDialog/CMakeLists.txt |
|
53 macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var) |
|
54 get_target_property(_qt_plugin_path "${_qt_plugin_name}" LOCATION) |
|
55 if(EXISTS "${_qt_plugin_path}") |
|
56 get_filename_component(_qt_plugin_file "${_qt_plugin_path}" NAME) |
|
57 get_filename_component(_qt_plugin_type "${_qt_plugin_path}" PATH) |
|
58 get_filename_component(_qt_plugin_type "${_qt_plugin_type}" NAME) |
|
59 set(_qt_plugin_dir "PlugIns") |
|
60 set(_qt_plugin_dest "${_qt_plugin_dir}/${_qt_plugin_type}") |
|
61 install(FILES "${_qt_plugin_path}" |
|
62 DESTINATION "../${_qt_plugin_dest}" # relative to install dir |
|
63 ${COMPONENT}) |
|
64 list(APPEND ${_qt_plugins_var} |
|
65 "\${CMAKE_BINARY_DIR}/${APP_BASE_DIR}/${_qt_plugin_dest}/${_qt_plugin_file}") |
|
66 else() |
|
67 message(FATAL_ERROR "QT plugin ${_qt_plugin_name} not found") |
|
68 endif() |
|
69 endmacro() |
|
70 |
|
71 # install cocoa plugin and build list to send to fixup_bundle |
|
72 install_qt5_plugin("Qt5::QCocoaIntegrationPlugin" QT_PLUGINS) |
|
73 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" |
|
74 "[Paths]\nPlugins = ${_qt_plugin_dir}\n") |
|
75 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" |
|
76 DESTINATION "../Resources" # relative to install dir |
|
77 ${COMPONENT}) |
|
78 |
|
79 # Build up search directories for fixup_bundle |
|
80 set(DIRS "") |
|
81 # Add QT bin and lib paths |
|
82 if(CMAKE_PREFIX_PATH) |
|
83 foreach(dir ${CMAKE_PREFIX_PATH}) |
|
84 list(APPEND DIRS "${dir}/bin" "${dir}/lib") |
|
85 endforeach() |
51 endif() |
86 endif() |
|
87 # Add other lib folder from around the system |
|
88 list(APPEND DIRS |
|
89 ~/Library/Frameworks |
|
90 /Library/Frameworks |
|
91 /usr/local/lib |
|
92 /opt/local/lib |
|
93 ) |
52 |
94 |
53 #create the .app bundle |
95 # operate on the Hedgewars.app |
54 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CreateMacBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake) |
96 set(APPS ${CMAKE_BINARY_DIR}/${APP_DIR}) |
55 install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake |
97 |
56 CODE "message(STATUS \"Your app bundle is ready\")") |
98 # debugging |
|
99 message(STATUS "APPS: ${APPS}") |
|
100 message(STATUS "QT_PLUGINS: ${QT_PLUGINS}") |
|
101 message(STATUS "DIRS: ${DIRS}") |
57 |
102 |
|
103 # properly fixup the .app to include all dependencies |
|
104 install(CODE "include(BundleUtilities) |
|
105 fixup_bundle(\"${APPS}\" \"${QT_PLUGINS}\" \"${DIRS}\")") |
|
106 |
|
107 |
58 #create the .dmg for deployment |
108 #create the .dmg for deployment |
59 #first make sure .app exists, then remove any old .dmg with same name, finally run the script |
109 #first make sure .app exists, then remove any old .dmg with same name, finally run the script |
60 add_custom_target(dmg COMMAND make install |
110 add_custom_target(dmg COMMAND make install |
61 COMMAND rm -f ${CMAKE_BINARY_DIR}/Hedgewars-${HEDGEWARS_VERSION}.dmg |
111 COMMAND rm -f ${CMAKE_BINARY_DIR}/Hedgewars-${HEDGEWARS_VERSION}.dmg |
62 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/create-dmg.sh |
112 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/create-dmg.sh |