source: subsurface/CMakeLists.txt

Last change on this file was 20f5609a, checked in by Dirk Hohndel <dirk@…>, 10 days ago

Mac build: correctly deal with no printing

Including working around a weird hack to install the Grantlee
plugins.

Signed-off-by: Dirk Hohndel <dirk@…>

  • Property mode set to 100644
File size: 21.6 KB
Line 
1# cmake based build of Subsurface
2
3# Uncomment his to see all commands cmake actually executes
4# set(CMAKE_VERBOSE_MAKEFILE ON)
5
6project(Subsurface)
7cmake_minimum_required(VERSION 2.8.11)
8
9# global settings
10
11set(CMAKE_AUTOMOC ON)
12include(cmake/Modules/MacroOutOfSourceBuild.cmake)
13MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
14    "We don't support building in source, please create a build folder elsewhere and remember to run git clean -xdf to remoev temporary files created by CMake."
15)
16
17#Options regarding usage of pkgconfig
18option(LIBGIT2_FROM_PKGCONFIG "use pkg-config to retrieve libgit2" OFF)
19option(LIBDC_FROM_PKGCONFIG "use pkg-config to retrieve libdivecomputer" OFF)
20option(LIBGRANTLEE_FROM_PKGCONFIG "use pkg-config to retrieve grantlee" OFF)
21option(LIBMARBLE_FROM_PKGCONFIG "use pkg-config to retrieve marble" OFF)
22
23#Library Handling
24option(FORCE_LIBSSH "force linking with libssh to workaround libgit2 bug" ON)
25option(LIBGIT2_DYNAMIC "search for libgit2.so before libgit2.a" OFF)
26
27#Options regarding disabling parts of subsurface.
28option(NO_MARBLE "disable the marble widget" OFF)
29option(NO_DOCS "disable the docs" OFF)
30option(NO_PRINTING "disable the printing support" OFF)
31option(NO_USERMANUAL "don't include a viewer for the user manual" OFF)
32
33#Options regarding enabling parts of subsurface
34option(FBSUPPORT "allow posting to Facebook" ON)
35option(BTSUPPORT "enable support for QtBluetooth (requires Qt5.4 or newer)" ON)
36option(FTDISUPPORT "enable support for libftdi based serial" OFF)
37option(USE_WEBENGINE "Use QWebEngine instead of QWebKit" OFF)
38
39# Options regarding What should we build on subsurface
40option(MAKE_TESTS "Make the tests" ON)
41
42SET(SUBSURFACE_TARGET_EXECUTABLE "DesktopExecutable" CACHE STRING "The type of application, DesktopExecutable or MobileExecutable")
43LIST(APPEND SUBSURFACE_ACCEPTED_EXECUTABLES  "DesktopExecutable" "MobileExecutable")
44SET_PROPERTY(CACHE SUBSURFACE_TARGET_EXECUTABLE PROPERTY STRINGS ${SUBSURFACE_ACCEPTED_EXECUTABLES})
45
46#verify if Platform is correct and warn on wxit with example.
47list (FIND SUBSURFACE_ACCEPTED_EXECUTABLES ${SUBSURFACE_TARGET_EXECUTABLE}  _index)
48if (${_index} EQUAL -1)
49  message(FATAL_ERROR "Requested platform not supported, please use one of the following:
50    ${SUBSURFACE_ACCEPTED_EXECUTABLES}
51
52    inputted value was: ${SUBSURFACE_TARGET_EXECUTABLE}
53
54    Example: -DSUBSURFACE_TARGET_EXECUTABLE=DesktopExecutable")
55endif()
56
57# SUBSURFACE_SOURCE may be used in subdirectories (tests)
58set(SUBSURFACE_SOURCE ${CMAKE_SOURCE_DIR})
59add_definitions(-DSUBSURFACE_SOURCE="${SUBSURFACE_SOURCE}")
60
61#evenrything's correct, moving on.
62set(CMAKE_MODULE_PATH
63        ${CMAKE_MODULE_PATH}
64        ${${PROJECT_NAME}_SOURCE_DIR}/cmake/Modules
65)
66
67#
68# TODO: This Compilation part should go on the Target specific CMake.
69#
70if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
71        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 ")
72        if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND
73           ((${CMAKE_SYSTEM_VERSION} MATCHES "11.4.") OR
74            (${CMAKE_OSX_DEPLOYMENT_TARGET} MATCHES "10.7") OR
75            (${CMAKE_OSX_DEPLOYMENT_TARGET} MATCHES "10.8")))
76                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
77        else()
78                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
79        endif()
80elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
81        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 ")
82        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
83elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
84        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
85        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
86
87        # Warn about possible float conversion errors
88        # Use NOT VERSION_LESS since VERSION_GREATER_EQUAL is not available
89        # in currently used cmake version.
90        if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9.0")
91                set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-conversion")
92                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfloat-conversion")
93        endif()
94
95elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
96  # using Intel C++
97elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
98  # using Visual Studio C++
99endif()
100
101# pkgconfig for required libraries
102find_package(PkgConfig)
103include(cmake/Modules/pkgconfig_helper.cmake)
104
105# The 'HandleFindXXX' are special libraries that subsurface needs
106# to find and configure in a few different ways because of a few
107# developers that prefer pkg-config over CMake, so we try to make
108# everyone happy. It also sets some variables for each library, so
109# if you think a module miss anything, take a look on the specific
110# module file.
111include(cmake/Modules/HandleFindGit2.cmake)
112include(cmake/Modules/HandleFindLibDiveComputer.cmake)
113if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
114        include(cmake/Modules/HandleFindMarble.cmake)
115        include(cmake/Modules/HandleFindGrantlee.cmake)
116        include(cmake/Modules/HandleUserManual.cmake)
117endif()
118include(cmake/Modules/HandleFtdiSupport.cmake)
119include(cmake/Modules/HandleVersionGeneration.cmake)
120include(cmake/Modules/RunOnBuildDir.cmake)
121include(cmake/Modules/cmake_variables_helper.cmake)
122
123pkg_config_library(LIBXML libxml-2.0 REQUIRED)
124pkg_config_library(LIBSQLITE3 sqlite3 REQUIRED)
125pkg_config_library(LIBXSLT libxslt REQUIRED)
126pkg_config_library(LIBZIP libzip REQUIRED)
127pkg_config_library(LIBUSB libusb-1.0 QUIET)
128
129include_directories(.
130        ${CMAKE_CURRENT_BINARY_DIR}
131        ${CMAKE_BINARY_DIR}
132        ${CMAKE_BINARY_DIR}/desktop-widgets
133)
134
135# Project Target specific configuration should go here,
136# if the configuration is too big or would disrupt the normal code flux,
137# move it somewhere else (another file) and include it.
138if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
139        if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
140                set(SUBSURFACE_TARGET Subsurface)
141        else()
142                set(SUBSURFACE_TARGET subsurface)
143        endif()
144        remove_definitions(-DSUBSURFACE_MOBILE)
145elseif(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
146        if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
147                set(SUBSURFACE_TARGET Subsurface-mobile)
148        else()
149                set(SUBSURFACE_TARGET subsurface-mobile)
150        endif()
151        list(APPEND QT_EXTRA_COMPONENTS Quick)
152        list(APPEND QT_EXTRA_COMPONENTS QuickControls2)
153        list(APPEND QT_EXTRA_LIBRARIES Qt5::Quick)
154        list(APPEND QT_EXTRA_LIBRARIES Qt5::QuickControls2)
155        add_definitions(-DSUBSURFACE_MOBILE)
156endif()
157
158if(ANDROID)
159        set(NO_PRINTING ON)
160        list(APPEND QT_EXTRA_COMPONENTS AndroidExtras)
161        list(APPEND QT_EXTRA_LIBRARIES Qt5::AndroidExtras)
162        set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -llog)
163elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
164        # add pthread to the end of the library list on Linux
165        # this is only needed on Ubuntu
166        # but shouldn't hurt on other Linux versions
167        # in some builds we appear to be missing libz for some strange reason...
168        # Add ssh2 at the end for openSUSE builds (for recent cmake?)
169        set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lssh2 -lz -lpthread)
170elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
171        execute_process(
172                COMMAND sh scripts/get-version linux
173                WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
174                OUTPUT_VARIABLE SSRF_VERSION_STRING
175                OUTPUT_STRIP_TRAILING_WHITESPACE
176        )
177        find_library(APP_SERVICES_LIBRARY ApplicationServices)
178        find_library(HID_LIB HidApi)
179        set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${HID_LIB})
180        set(EXTRA_LIBS ${APP_SERVICES_LIBRARY})
181        set(ICON_FILE ${CMAKE_SOURCE_DIR}/packaging/macosx/Subsurface.icns)
182        if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
183                set(MACOSX_BUNDLE_INFO_STRING "Subsurface-mobile")
184                set(MACOSX_BUNDLE_BUNDLE_NAME "Subsurface-mobile")
185        else()
186                set(MACOSX_BUNDLE_INFO_STRING "Subsurface")
187                set(MACOSX_BUNDLE_BUNDLE_NAME "Subsurface")
188        endif()
189        set(MACOSX_BUNDLE_ICON_FILE Subsurface.icns)
190        set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.subsurface-divelog")
191        set(MACOSX_BUNDLE_BUNDLE_VERSION "${SSRF_VERSION_STRING}")
192        set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${SSRF_VERSION_STRING}")
193        set(MACOSX_BUNDLE_LONG_VERSION_STRING "${SSRF_VERSION_STRING}")
194        set(MACOSX_BUNDLE_COPYRIGHT "Linus Torvalds, Dirk Hohndel, Tomaz Canabrava, and others")
195        set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
196        set(SUBSURFACE_PKG MACOSX_BUNDLE ${ICON_FILE})
197elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
198        set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lwsock32 -lws2_32)
199        remove_definitions(-DUNICODE)
200        add_definitions(-mwindows -D_WIN32)
201endif()
202
203if(BTSUPPORT)
204        list(APPEND QT_EXTRA_COMPONENTS Bluetooth)
205        list(APPEND QT_EXTRA_LIBRARIES Qt5::Bluetooth)
206endif()
207
208find_package(Qt5 REQUIRED COMPONENTS Core Concurrent Widgets Network Svg Test LinguistTools Positioning ${QT_EXTRA_COMPONENTS})
209set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network Qt5::Svg  Qt5::Positioning ${QT_EXTRA_LIBRARIES})
210set(QT_TEST_LIBRARIES ${QT_LIBRARIES} Qt5::Test)
211
212#disable bluetooth if Qt version is ancient.
213if (BTSUPPORT AND "${Qt5Core_VERSION}" VERSION_LESS 5.4.0)
214        set(BTSUPPORT OFF)
215        message(STATUS "Turning off Bluetooth support as Qt version ${Qt5Core_VERSION} is insufficient for that")
216        list(REMOVE_ITEM QT_LIBRARIES Qt5::Bluetooth)
217endif()
218
219# Windows Qt doesn't support BLE at all
220# Mac hasn't been tested, yet - so far it's disabled
221# the rest of them need at least 5.6 to be reasonable but really, you want 5.9.1
222if (BTSUPPORT AND (ANDROID OR CMAKE_SYSTEM_NAME STREQUAL "Linux"))
223        if ("${Qt5Core_VERSION}" VERSION_LESS 5.6.0)
224                message(STATUS "Turning off BLE support as Qt version ${Qt5Core_VERSION} is insufficient for that")
225        else()
226                set(BLESUPPORT ON)
227                if ("${Qt5Core_VERSION}" VERSION_LESS 5.9.1)
228                        message(STATUS "BLE support has been enabled, but for best results you really want Qt 5.9.1")
229                endif()
230        endif()
231endif()
232
233if(BTSUPPORT)
234        add_definitions(-DBT_SUPPORT)
235endif()
236
237if(BLESUPPORT)
238        add_definitions(-DBLE_SUPPORT)
239endif()
240
241#set up the subsurface_link_libraries variable
242set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${LIBDIVECOMPUTER_LIBRARIES} ${LIBGIT2_LIBRARIES} ${LIBUSB_LIBRARIES})
243qt5_add_resources(SUBSURFACE_RESOURCES subsurface.qrc)
244
245# include translations
246add_subdirectory(translations)
247add_subdirectory(core)
248add_subdirectory(qt-models)
249add_subdirectory(profile-widget)
250
251if (${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
252        add_subdirectory(desktop-widgets)
253endif()
254
255# create the executables
256if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
257        set(MOBILE_SRC
258                mobile-widgets/qmlmanager.cpp
259                mobile-widgets/qmlprofile.cpp
260                mobile-widgets/qml/kirigami/src/kirigamiplugin.cpp
261                mobile-widgets/qml/kirigami/src/settings.cpp
262                mobile-widgets/qml/kirigami/src/enums.cpp
263                subsurface-mobile-main.cpp
264                subsurface-mobile-helper.cpp
265        )
266        if(NOT ANDROID AND NOT iOS)
267                set(MOBILE_SRC ${MOBILE_SRC} mobile-widgets/qml/kirigami/src/desktopicon.cpp)
268        endif()
269        add_definitions(-DKIRIGAMI_BUILD_TYPE_STATIC)
270        qt5_add_resources(MOBILE_RESOURCES mobile-widgets/qml/mobile-resources.qrc)
271        qt5_add_resources(MOBILE_RESOURCES mobile-widgets/qml/kirigami/kirigami.qrc)
272        # When building the mobile application in Android, link it and Qt will do the rest, when doing the mobile application on Desktop, create an executable.
273        if(ANDROID)
274                add_library(${SUBSURFACE_TARGET} SHARED ${SUBSURFACE_PKG} ${MOBILE_SRC} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES})
275        else()
276                add_executable(${SUBSURFACE_TARGET} MACOSX_BUNDLE WIN32 ${SUBSURFACE_PKG} ${MOBILE_SRC} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES})
277        endif()
278        target_link_libraries(
279                ${SUBSURFACE_TARGET}
280                subsurface_profile
281                subsurface_models
282                subsurface_corelib
283                ${SUBSURFACE_LINK_LIBRARIES}
284        )
285elseif(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
286        set(SUBSURFACE_APP
287                subsurface-desktop-main.cpp
288                subsurface-desktop-helper.cpp
289        )
290        source_group("Subsurface App" FILES ${SUBSURFACE_APP})
291        if(ANDROID)
292                add_library(${SUBSURFACE_TARGET} SHARED ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES})
293        else()
294                add_executable(${SUBSURFACE_TARGET} MACOSX_BUNDLE WIN32 ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES})
295        endif()
296
297        if(FBSUPPORT)
298                set(FACEBOOK_INTEGRATION facebook_integration)
299        endif()
300        target_link_libraries(
301                ${SUBSURFACE_TARGET}
302                subsurface_generated_ui
303                subsurface_interface
304                ${FACEBOOK_INTEGRATION}
305                subsurface_profile
306                subsurface_statistics
307                subsurface_models
308                subsurface_corelib
309                ${SUBSURFACE_LINK_LIBRARIES}
310        )
311        add_dependencies(subsurface_statistics subsurface_generated_ui)
312        add_dependencies(subsurface_interface subsurface_generated_ui)
313        add_dependencies(subsurface_profile subsurface_generated_ui)
314        add_dependencies(subsurface_models subsurface_generated_ui)
315        add_dependencies(subsurface_generated_ui version)
316endif()
317
318add_dependencies(subsurface_corelib version)
319
320# add platform specific actions
321if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
322        add_custom_command(
323                OUTPUT ${CMAKE_BINARY_DIR}/qt.conf
324                COMMAND echo \"[Paths]\" > ${CMAKE_BINARY_DIR}/qt.conf \; echo \"Prefix=.\" >> ${CMAKE_BINARY_DIR}/qt.conf
325        )
326        add_custom_target(
327                generate_qtconf
328                DEPENDS ${CMAKE_BINARY_DIR}/qt.conf
329        )
330        add_dependencies(${SUBSURFACE_TARGET} generate_qtconf)
331endif()
332
333# build an automated html exporter
334add_executable(export-html EXCLUDE_FROM_ALL export-html.cpp ${SUBSURFACE_RESOURCES})
335target_link_libraries(export-html subsurface_corelib ${SUBSURFACE_LINK_LIBRARIES})
336
337# install Subsurface
338# first some variables with files that need installing
339set(DOCFILES
340        README
341        ReleaseNotes/ReleaseNotes.txt
342        SupportedDivecomputers.txt
343        ${CMAKE_BINARY_DIR}/Documentation/user-manual.html
344        ${CMAKE_BINARY_DIR}/Documentation/user-manual_es.html
345        ${CMAKE_BINARY_DIR}/Documentation/user-manual_fr.html
346        ${CMAKE_BINARY_DIR}/Documentation/user-manual_ru.html
347)
348
349# add all the translations that we may need
350FILE(STRINGS "subsurface_enabled_translations" QTTRANSLATIONS_BASE)
351
352if(NOT DEFINED QT_TRANSLATION_DIR OR QT_TRANSLATION_DIR STREQUAL "")
353        set(QT_TRANSLATION_DIR ${Qt5Core_DIR}/../../../translations)
354endif()
355set(QTTRANSLATIONS "")
356foreach(QTTRANSLATION ${QTTRANSLATIONS_BASE})
357        if(NOT ${QTTRANSLATION} STREQUAL "")
358                if(EXISTS ${QT_TRANSLATION_DIR}/${QTTRANSLATION})
359                        set(QTTRANSLATIONS ${QTTRANSLATIONS} ${QT_TRANSLATION_DIR}/${QTTRANSLATION})
360                endif()
361        endif()
362endforeach()
363
364# now for each platform the install instructions
365if(ANDROID)
366        # Android template directory
367        include(${QT_ANDROID_CMAKE})
368        if((DEFINED ENV{KEYSTORE}) AND (DEFINED ENV{KEYSTORE_PASSWORD}))
369                add_qt_android_apk(${SUBSURFACE_TARGET}.apk ${SUBSURFACE_TARGET}
370                        PACKAGE_SOURCES ${CMAKE_BINARY_DIR}/android-mobile DEPENDS ${ANDROID_NATIVE_LIBSSL} ${ANDROID_NATIVE_LIBCRYPT}
371                        BUILDTOOLS_REVISION ${BUILDTOOLS_REVISION}
372                        KEYSTORE $ENV{KEYSTORE} Subsurface-mobile KEYSTORE_PASSWORD $ENV{KEYSTORE_PASSWORD}
373                )
374                message(STATUS "KEYSTORE=$ENV{KEYSTORE} KEYSTORE_PASSWORD=$ENV{KEYSTORE_PASSWORD}")
375        else()
376                add_qt_android_apk(${SUBSURFACE_TARGET}.apk ${SUBSURFACE_TARGET}
377                        PACKAGE_SOURCES ${CMAKE_BINARY_DIR}/android-mobile DEPENDS ${ANDROID_NATIVE_LIBSSL} ${ANDROID_NATIVE_LIBCRYPT}
378                        BUILDTOOLS_REVISION ${BUILDTOOLS_REVISION}
379                )
380                message(STATUS "no KEYSTORE")
381        endif()
382elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
383        set(APP_BUNDLE_DIR "${SUBSURFACE_TARGET}.app")
384        if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
385                set(EXTRA_MACDEPLOY_ARGS "-qmldir=${APP_BUNDLE_DIR}/Contents/Frameworks/qml ")
386        endif()
387        set(MACDEPLOY_ARGS "${EXTRA_MACDEPLOY_ARGS}-executable=${APP_BUNDLE_DIR}/Contents/MacOS/${SUBSURFACE_TARGET} -always-overwrite")
388        set(RESOURCEDIR ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Resources)
389        set(PLUGINDIR ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/PlugIns)
390        install(DIRECTORY marbledata/maps DESTINATION ${RESOURCEDIR}/data)
391        install(DIRECTORY marbledata/bitmaps DESTINATION ${RESOURCEDIR}/data)
392        install(DIRECTORY Documentation/images DESTINATION ${RESOURCEDIR}/share/Documentation)
393        install(FILES ${DOCFILES} DESTINATION ${RESOURCEDIR}/share/Documentation)
394        install(DIRECTORY theme DESTINATION ${RESOURCEDIR})
395        install(DIRECTORY printing_templates DESTINATION ${RESOURCEDIR})
396        install(FILES ${TRANSLATIONS} DESTINATION ${RESOURCEDIR}/translations)
397        install(FILES ${QTTRANSLATIONS} DESTINATION ${RESOURCEDIR}/translations)
398        install(FILES ${CMAKE_SOURCE_DIR}/gpl-2.0.txt DESTINATION ${RESOURCEDIR})
399        # this is a HACK
400        if((${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable") AND (NOT NO_PRINTING))
401                install(DIRECTORY ${Grantlee5_DIR}/../../grantlee DESTINATION ${PLUGINDIR})
402        endif()
403        # this is a hack - but I don't know how else to find the macdeployqt program if it's not in the PATH
404        string(REPLACE moc macdeployqt MACDEPLOYQT ${QT_MOC_EXECUTABLE})
405        install(CODE "execute_process(COMMAND ${MACDEPLOYQT} ${APP_BUNDLE_DIR} ${MACDEPLOY_ARGS})")
406        # and another hack to get the QML Components in the right place
407        if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
408                install(CODE "execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/qml)")
409                install(CODE "execute_process(COMMAND cp -a ${_qt5Core_install_prefix}/qml/QtQuick ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/qml)")
410        endif()
411        if(NOT NO_MARBLE)
412                # more hackery - this time for QtXml which is needed by libssrfmarblewidget
413                install(CODE "execute_process(COMMAND cp -a ${_qt5Core_install_prefix}/lib/QtXml.framework ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks)")
414                install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/Versions/5/Headers)")
415                install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/Headers)")
416                install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/QtXml.prl)")
417                install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/Versions/5/QtXml_debug)")
418                install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/QtXml_debug)")
419                install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/QtXml_debug.prl)")
420                install(CODE "execute_process(COMMAND install_name_tool -id @executable_path/../Frameworks/QtXml ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/QtXml)")
421                install(CODE "execute_process(COMMAND install_name_tool -change @rpath/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/QtCore ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/QtXml)")
422        endif()
423        install(CODE "message(STATUS \"two ERRORS here about libmysqlclient and libpq not found are harmless\")")
424elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
425        # Windows bundling rules
426        # We don't have a helpful tool like macdeployqt for Windows, so we hardcode
427        # which libs we need.
428        # "make install", copies everything into a staging area
429        # "make installer", uses makensis to create an installer executable
430        set(WINDOWSSTAGING ${CMAKE_BINARY_DIR}/staging)
431        install(DIRECTORY marbledata/maps DESTINATION ${WINDOWSSTAGING}/data)
432        install(DIRECTORY marbledata/bitmaps DESTINATION ${WINDOWSSTAGING}/data)
433        install(DIRECTORY Documentation/images DESTINATION ${WINDOWSSTAGING}/Documentation)
434        install(FILES ${DOCFILES} DESTINATION ${WINDOWSSTAGING}/Documentation)
435        install(DIRECTORY theme DESTINATION ${WINDOWSSTAGING})
436        install(DIRECTORY printing_templates DESTINATION ${WINDOWSSTAGING})
437        install(FILES ${TRANSLATIONS} DESTINATION ${WINDOWSSTAGING}/translations)
438        install(FILES ${QTTRANSLATIONS} DESTINATION ${WINDOWSSTAGING}/translations)
439        install(FILES ${CMAKE_SOURCE_DIR}/gpl-2.0.txt ${CMAKE_SOURCE_DIR}/packaging/windows/subsurface.ico DESTINATION ${WINDOWSSTAGING})
440        install(TARGETS ${SUBSURFACE_TARGET} DESTINATION ${WINDOWSSTAGING})
441        install(FILES ${CMAKE_BINARY_DIR}/qt.conf DESTINATION ${WINDOWSSTAGING})
442        install(DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/grantlee DESTINATION ${WINDOWSSTAGING})
443        if(NOT DEFINED MAKENSIS)
444                set(MAKENSIS makensis)
445        endif()
446
447        # the script we created above is now added as a command to run at
448        # install time - so this ensures that subsurface.exe has been
449        # built before this is run
450        install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DSUBSURFACE_TARGET=${SUBSURFACE_TARGET} -DSUBSURFACE_SOURCE=${SUBSURFACE_SOURCE} -DSTAGING=${WINDOWSSTAGING} -P ${CMAKE_SOURCE_DIR}/cmake/Modules/dlllist.cmake)")
451
452        # create the subsurface-x.y.z.exe installer - this needs to depend
453        # on the install target but cmake doesn't allow that, so we depend
454        # on the fake target instead
455        add_custom_target(
456                fake_install
457                COMMAND "${CMAKE_COMMAND}" --build . --target install
458                DEPENDS ${SUBSURFACE_TARGET}
459        )
460
461        add_custom_target(
462                installer
463                COMMAND ${MAKENSIS} ${WINDOWSSTAGING}/subsurface.nsi
464                DEPENDS fake_install
465        )
466elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
467        install(DIRECTORY marbledata/maps DESTINATION share/subsurface/data)
468        install(DIRECTORY marbledata/bitmaps DESTINATION share/subsurface/data)
469        install(FILES subsurface.debug DESTINATION bin)
470        install(FILES subsurface.desktop DESTINATION share/applications)
471        install(FILES icons/subsurface-icon.svg DESTINATION share/icons/hicolor/scalable/apps)
472        install(DIRECTORY Documentation/images DESTINATION share/subsurface/Documentation)
473        install(FILES ${DOCFILES} DESTINATION share/subsurface/Documentation)
474        install(DIRECTORY theme DESTINATION share/subsurface)
475        install(DIRECTORY printing_templates DESTINATION share/subsurface)
476        install(FILES ${TRANSLATIONS} DESTINATION share/subsurface/translations)
477        install(TARGETS ${SUBSURFACE_TARGET} DESTINATION bin)
478        if(DEFINED LIBMARBLEDEVEL)
479                install(
480                        CODE "file(GLOB SSRFMARBLE_SHLIBS \"${LIBMARBLEDEVEL}/lib/libssrfmarblewidget.so*\")"
481                        CODE "file(INSTALL \${SSRFMARBLE_SHLIBS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)"
482                )
483        endif()
484endif()
485
486if (MAKE_TESTS)
487        add_subdirectory(tests)
488endif()
489
490# useful for debugging CMake issues
491# print_all_variables()
Note: See TracBrowser for help on using the repository browser.