1 if (NOT APPLE) |
1 if(NOT APPLE) |
2 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" |
2 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" |
3 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" |
3 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" |
4 IMMEDIATE @ONLY) |
4 IMMEDIATE @ONLY) |
5 |
5 |
6 add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") |
6 add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") |
7 endif() |
7 endif() |
8 |
8 |
9 if (APPLE) |
9 if(APPLE AND NOT SKIPBUNDLE) |
10 find_package(Qt4 REQUIRED QUIET) |
10 find_package(Qt5 REQUIRED QUIET COMPONENTS Core Widgets Gui Network) |
11 find_package(SDL REQUIRED) |
11 find_package(SDL2 REQUIRED) |
12 find_package(SDL_image REQUIRED) |
12 find_package(SDL2_image 2 REQUIRED) |
13 find_package(SDL_net REQUIRED) |
13 find_package(SDL2_net 2 REQUIRED) |
14 find_package(SDL_ttf REQUIRED) |
14 find_package(SDL2_ttf 2 REQUIRED) |
15 find_package(SDL_mixer REQUIRED) |
15 find_package(SDL2_mixer 2 REQUIRED) |
16 find_package(OGGVORBIS REQUIRED) |
16 find_package(OggVorbis REQUIRED) |
|
17 find_package(PNG REQUIRED) |
|
18 |
17 if(NOT NOAUTOUPDATE) |
19 if(NOT NOAUTOUPDATE) |
18 #needed for SPARKLE_FOUND variable |
20 find_package(Sparkle) #needed for SPARKLE_FOUND variable |
19 find_package(Sparkle QUIET) |
|
20 #needed because the 'if' clause in the script prints silly policy warnings |
21 #needed because the 'if' clause in the script prints silly policy warnings |
21 if(${SPARKLE_FOUND}) |
22 if(SPARKLE_FOUND) |
22 set(SPARKLE_FOUND 1) |
23 set(SPARKLE_FOUND 1) |
23 else() |
24 else() |
24 set(SPARKLE_FOUND 0) |
25 set(SPARKLE_FOUND 0) |
25 endif() |
26 endif() |
26 endif() |
27 endif() |
27 |
28 |
28 #use the associated tool from the libraries we've selected |
29 #remove the ";-framework Cocoa" from the SDL2_LIBRARY variable |
29 string(REGEX REPLACE "(.*)/include.*" "\\1" qt_base_dir "${QT_INCLUDE_DIR}") |
30 string(REGEX REPLACE "(.*);-.*" "\\1" sdl_library_only "${SDL2_LIBRARY}") |
|
31 #remove the "libSDLmain.a" from the SDL2_LIBRARY variable |
|
32 string(REGEX REPLACE ".*;(.*)" "\\1" sdl_library_only "${sdl_library_only}") |
30 |
33 |
31 #remove the ";-framework Cocoa" from the SDL_LIBRARY variable |
34 #get the neme of the library (harmelss if it is static) |
32 string(REGEX REPLACE "(.*);-.*" "\\1" sdl_dir "${SDL_LIBRARY}") |
35 string(REGEX REPLACE ".*/(.*)$" "\\1" PNG_LIBNAME "${PNG_LIBRARY}") |
|
36 string(REGEX REPLACE ".*/(.*)$" "\\1" ZLIB_LIBNAME "${ZLIB_LIBRARY}") |
33 |
37 |
34 if(NOT NOPNG) |
38 set(frameworks_dir ${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}) |
35 #get the neme of the library (harmelss if it is static) |
39 |
36 string(REGEX REPLACE ".*/(.*)$" "\\1" PNG_LIBNAME "${PNG_LIBRARY}") |
40 if(${BUILD_ENGINE_LIBRARY}) |
|
41 set(engine_full_path "${frameworks_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}") |
|
42 else() |
|
43 set(engine_full_path "${CMAKE_INSTALL_PREFIX}/hwengine${CMAKE_EXECUTABLE_SUFFIX}") |
37 endif() |
44 endif() |
38 |
45 |
39 #this tool is present in qt 4.5 but only if you compile from sources |
46 |
40 #from qt 4.6 is present also in the binary version |
47 #create the .app bundle using BundleUtilities instead of old macdeployqt |
41 find_program(macdeployqt_executable NAMES macdeployqt macdeployqt-mac PATHS ${qt_base_dir}/bin) |
48 set(APP_DIR "Hedgewars.app") |
42 if(NOT macdeployqt_executable) |
49 set(APP_BASE_DIR "${CMAKE_INSTALL_PREFIX}/../") # should be, Hedgewars.app/Contents/MacOS/../ |
43 message(FATAL_ERROR "The utility macdeployqt is required to create the bundle (seached: ${qt_base_dir})") |
50 |
44 else() |
51 # macro to install qt5 plugins |
45 message(STATUS "Found macdeployqt: ${macdeployqt_executable}") |
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() |
46 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 ) |
47 |
94 |
48 #dummy target, we're interested in the postscript file |
95 # operate on the Hedgewars.app |
49 add_custom_target(bundle) |
96 set(APPS ${CMAKE_BINARY_DIR}/${APP_DIR}) |
50 set_target_properties(bundle PROPERTIES POST_INSTALL_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake) |
97 |
|
98 # debugging |
|
99 message(STATUS "APPS: ${APPS}") |
|
100 message(STATUS "QT_PLUGINS: ${QT_PLUGINS}") |
|
101 message(STATUS "DIRS: ${DIRS}") |
51 |
102 |
52 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CreateMacBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake) |
103 # properly fixup the .app to include all dependencies |
|
104 install(CODE "include(BundleUtilities) |
|
105 fixup_bundle(\"${APPS}\" \"${QT_PLUGINS}\" \"${DIRS}\")") |
|
106 |
|
107 |
|
108 #create the .dmg for deployment |
|
109 #first make sure .app exists, then remove any old .dmg with same name, finally run the script |
|
110 add_custom_target(dmg COMMAND make install |
|
111 COMMAND rm -f ${CMAKE_BINARY_DIR}/Hedgewars-${HEDGEWARS_VERSION}.dmg |
|
112 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/create-dmg.sh |
|
113 --volname "Hedgewars ${HEDGEWARS_VERSION}" |
|
114 # --volicon icon.icns |
|
115 --window-size 600 470 |
|
116 --icon-size 96 |
|
117 --icon "Hedgewars" 190 190 |
|
118 --app-drop-link 410 190 |
|
119 --background "${CMAKE_CURRENT_SOURCE_DIR}/../misc/dmgBackground.png" |
|
120 ${CMAKE_BINARY_DIR}/Hedgewars-${HEDGEWARS_VERSION}.dmg |
|
121 ${CMAKE_BINARY_DIR}/${APP_DIR} |
|
122 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) |
53 endif() |
123 endif() |
54 |
124 |