source: subsurface/CMakeLists.txt

Last change on this file was 3a003f4c, checked in by Dirk Hohndel <dirk@…>, 8 weeks ago

QML UI: we now depend on QuckControls2

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

  • Property mode set to 100644
File size: 21.1 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
42#Extra features
43option(SMARTTRAK_IMPORT "enable building SmartTrak divelogs import tool (requires glib2 and libmdb)" OFF)
44
45SET(SUBSURFACE_TARGET_EXECUTABLE "DesktopExecutable" CACHE STRING "The type of application, DesktopExecutable or MobileExecutable")
46LIST(APPEND SUBSURFACE_ACCEPTED_EXECUTABLES  "DesktopExecutable" "MobileExecutable")
47SET_PROPERTY(CACHE SUBSURFACE_TARGET_EXECUTABLE PROPERTY STRINGS ${SUBSURFACE_ACCEPTED_EXECUTABLES})
48
49#verify if Platform is correct and warn on wxit with example.
50list (FIND SUBSURFACE_ACCEPTED_EXECUTABLES ${SUBSURFACE_TARGET_EXECUTABLE}  _index)
51if (${_index} EQUAL -1)
52  message(FATAL_ERROR "Requested platform not supported, please use one of the following:
53    ${SUBSURFACE_ACCEPTED_EXECUTABLES}
54
55    inputted value was: ${SUBSURFACE_TARGET_EXECUTABLE}
56
57    Example: -DSUBSURFACE_TARGET_EXECUTABLE=DesktopExecutable")
58endif()
59
60# SUBSURFACE_SOURCE may be used in subdirectories (tests)
61set(SUBSURFACE_SOURCE ${CMAKE_SOURCE_DIR})
62add_definitions(-DSUBSURFACE_SOURCE="${SUBSURFACE_SOURCE}")
63
64#evenrything's correct, moving on.
65set(CMAKE_MODULE_PATH
66        ${CMAKE_MODULE_PATH}
67        ${${PROJECT_NAME}_SOURCE_DIR}/cmake/Modules
68)
69
70#
71# TODO: This Compilation part should go on the Target specific CMake.
72#
73if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
74        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 ")
75        if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND
76           ((${CMAKE_SYSTEM_VERSION} MATCHES "11.4.") OR
77            (${CMAKE_OSX_DEPLOYMENT_TARGET} MATCHES "10.7") OR
78            (${CMAKE_OSX_DEPLOYMENT_TARGET} MATCHES "10.8")))
79                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
80        else()
81                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
82        endif()
83elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
84        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 ")
85        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
86elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
87        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
88        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
89
90        # Warn about possible float conversion errors
91        # Use NOT VERSION_LESS since VERSION_GREATER_EQUAL is not available
92        # in currently used cmake version.
93        if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9.0")
94                set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-conversion")
95                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfloat-conversion")
96        endif()
97
98elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
99  # using Intel C++
100elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
101  # using Visual Studio C++
102endif()
103
104# pkgconfig for required libraries
105find_package(PkgConfig)
106include(cmake/Modules/pkgconfig_helper.cmake)
107
108# The 'HandleFindXXX' are special libraries that subsurface needs
109# to find and configure in a few different ways because of a few
110# developers that prefer pkg-config over CMake, so we try to make
111# everyone happy. It also sets some variables for each library, so
112# if you think a module miss anything, take a look on the specific
113# module file.
114include(cmake/Modules/HandleFindGit2.cmake)
115include(cmake/Modules/HandleFindLibDiveComputer.cmake)
116if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
117        include(cmake/Modules/HandleFindMarble.cmake)
118        include(cmake/Modules/HandleFindGrantlee.cmake)
119        include(cmake/Modules/HandleUserManual.cmake)
120endif()
121include(cmake/Modules/HandleFtdiSupport.cmake)
122include(cmake/Modules/HandleVersionGeneration.cmake)
123include(cmake/Modules/RunOnBuildDir.cmake)
124include(cmake/Modules/cmake_variables_helper.cmake)
125
126pkg_config_library(LIBXML libxml-2.0 REQUIRED)
127pkg_config_library(LIBSQLITE3 sqlite3 REQUIRED)
128pkg_config_library(LIBXSLT libxslt REQUIRED)
129pkg_config_library(LIBZIP libzip REQUIRED)
130pkg_config_library(LIBUSB libusb-1.0 QUIET)
131
132if(SMARTTRAK_IMPORT)
133        pkg_config_library(GLIB2 glib-2.0 REQUIRED)
134        pkg_config_library(LIBMDB libmdb REQUIRED)
135endif()
136
137include_directories(.
138        ${CMAKE_CURRENT_BINARY_DIR}
139        ${CMAKE_BINARY_DIR}
140        ${CMAKE_BINARY_DIR}/desktop-widgets
141)
142
143# Project Target specific configuration should go here,
144# if the configuration is too big or would disrupt the normal code flux,
145# move it somewhere else (another file) and include it.
146if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
147        if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
148                set(SUBSURFACE_TARGET Subsurface)
149        else()
150                set(SUBSURFACE_TARGET subsurface)
151        endif()
152        remove_definitions(-DSUBSURFACE_MOBILE)
153elseif(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
154        if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
155                set(SUBSURFACE_TARGET Subsurface-mobile)
156        else()
157                set(SUBSURFACE_TARGET subsurface-mobile)
158        endif()
159        list(APPEND QT_EXTRA_COMPONENTS Quick)
160        list(APPEND QT_EXTRA_COMPONENTS QuickControls2)
161        list(APPEND QT_EXTRA_LIBRARIES Qt5::Quick)
162        list(APPEND QT_EXTRA_LIBRARIES Qt5::QuickControls2)
163        add_definitions(-DSUBSURFACE_MOBILE)
164endif()
165
166if(ANDROID)
167        set(NO_PRINTING ON)
168        list(APPEND QT_EXTRA_COMPONENTS AndroidExtras)
169        list(APPEND QT_EXTRA_LIBRARIES Qt5::AndroidExtras)
170        set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -llog)
171elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
172        # add pthread to the end of the library list on Linux
173        # this is only needed on Ubuntu
174        # but shouldn't hurt on other Linux versions
175        # in some builds we appear to be missing libz for some strange reason...
176        # Add ssh2 at the end for openSUSE builds (for recent cmake?)
177        set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lssh2 -lz -lpthread)
178elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
179        execute_process(
180                COMMAND sh scripts/get-version linux
181                WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
182                OUTPUT_VARIABLE SSRF_VERSION_STRING
183                OUTPUT_STRIP_TRAILING_WHITESPACE
184        )
185        find_library(APP_SERVICES_LIBRARY ApplicationServices)
186        find_library(HID_LIB HidApi)
187        set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${HID_LIB})
188        set(EXTRA_LIBS ${APP_SERVICES_LIBRARY})
189        set(ICON_FILE ${CMAKE_SOURCE_DIR}/packaging/macosx/Subsurface.icns)
190        if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
191                set(MACOSX_BUNDLE_INFO_STRING "Subsurface-mobile")
192                set(MACOSX_BUNDLE_BUNDLE_NAME "Subsurface-mobile")
193        else()
194                set(MACOSX_BUNDLE_INFO_STRING "Subsurface")
195                set(MACOSX_BUNDLE_BUNDLE_NAME "Subsurface")
196        endif()
197        set(MACOSX_BUNDLE_ICON_FILE Subsurface.icns)
198        set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.subsurface-divelog")
199        set(MACOSX_BUNDLE_BUNDLE_VERSION "${SSRF_VERSION_STRING}")
200        set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${SSRF_VERSION_STRING}")
201        set(MACOSX_BUNDLE_LONG_VERSION_STRING "${SSRF_VERSION_STRING}")
202        set(MACOSX_BUNDLE_COPYRIGHT "Linus Torvalds, Dirk Hohndel, Tomaz Canabrava, and others")
203        set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
204        set(SUBSURFACE_PKG MACOSX_BUNDLE ${ICON_FILE})
205elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
206        set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lwsock32 -lws2_32)
207        remove_definitions(-DUNICODE)
208        add_definitions(-mwindows -D_WIN32)
209endif()
210
211if(BTSUPPORT)
212        list(APPEND QT_EXTRA_COMPONENTS Bluetooth)
213        list(APPEND QT_EXTRA_LIBRARIES Qt5::Bluetooth)
214endif()
215
216find_package(Qt5 REQUIRED COMPONENTS Core Concurrent Widgets Network Svg Test LinguistTools Positioning ${QT_EXTRA_COMPONENTS})
217set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network Qt5::Svg  Qt5::Positioning ${QT_EXTRA_LIBRARIES})
218set(QT_TEST_LIBRARIES ${QT_LIBRARIES} Qt5::Test)
219
220#disable bluetooth if Qt version is ancient.
221if (BTSUPPORT AND "${Qt5Core_VERSION_STRING}" STRLESS "5.4.0")
222        set(BTSUPPORT OFF)
223        message(STATUS "Turning off Bluetooth support as Qt version ${Qt5Core_VERSION_STRING} is insufficient for that")
224        list(REMOVE_ITEM QT_LIBRARIES Qt5::Bluetooth)
225endif()
226
227if(BTSUPPORT)
228        add_definitions(-DBT_SUPPORT)
229endif()
230
231#set up the subsurface_link_libraries variable
232set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${LIBDIVECOMPUTER_LIBRARIES} ${LIBGIT2_LIBRARIES} ${LIBUSB_LIBRARIES})
233qt5_add_resources(SUBSURFACE_RESOURCES subsurface.qrc)
234
235# include translations
236add_subdirectory(translations)
237add_subdirectory(core)
238add_subdirectory(qt-models)
239add_subdirectory(profile-widget)
240
241if(SMARTTRAK_IMPORT)
242        add_subdirectory(smtk-import)
243endif()
244
245if (${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
246        add_subdirectory(desktop-widgets)
247endif()
248
249# create the executables
250if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
251        set(MOBILE_SRC
252                mobile-widgets/qmlmanager.cpp
253                mobile-widgets/qmlprofile.cpp
254                mobile-widgets/qml/kirigami/src/kirigamiplugin.cpp
255                mobile-widgets/qml/kirigami/src/settings.cpp
256                mobile-widgets/qml/kirigami/src/enums.cpp
257                subsurface-mobile-main.cpp
258                subsurface-mobile-helper.cpp
259        )
260        if(NOT ANDROID AND NOT iOS)
261                set(MOBILE_SRC ${MOBILE_SRC} mobile-widgets/qml/kirigami/src/desktopicon.cpp)
262        endif()
263        add_definitions(-DKIRIGAMI_BUILD_TYPE_STATIC)
264        qt5_add_resources(MOBILE_RESOURCES mobile-widgets/qml/mobile-resources.qrc)
265        qt5_add_resources(MOBILE_RESOURCES mobile-widgets/qml/kirigami/kirigami.qrc)
266        # 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.
267        if(ANDROID)
268                add_library(${SUBSURFACE_TARGET} SHARED ${SUBSURFACE_PKG} ${MOBILE_SRC} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES})
269        else()
270                add_executable(${SUBSURFACE_TARGET} MACOSX_BUNDLE WIN32 ${SUBSURFACE_PKG} ${MOBILE_SRC} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES})
271        endif()
272        target_link_libraries(
273                ${SUBSURFACE_TARGET}
274                subsurface_profile
275                subsurface_models
276                subsurface_corelib
277                ${SUBSURFACE_LINK_LIBRARIES}
278        )
279elseif(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
280        set(SUBSURFACE_APP
281                subsurface-desktop-main.cpp
282                subsurface-desktop-helper.cpp
283        )
284        source_group("Subsurface App" FILES ${SUBSURFACE_APP})
285        if(ANDROID)
286                add_library(${SUBSURFACE_TARGET} SHARED ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES})
287        else()
288                add_executable(${SUBSURFACE_TARGET} MACOSX_BUNDLE WIN32 ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES})
289        endif()
290
291        if(SMARTTRAK_IMPORT)
292                set(SMTK_IMPORT_TARGET smtk2ssrf)
293                add_executable(smtk2ssrf smtk-import/smtk_standalone.cpp ${SUBSURFACE_RESOURCES})
294                target_link_libraries(smtk2ssrf smtk_import)
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        add_qt_android_apk(${SUBSURFACE_TARGET}.apk ${SUBSURFACE_TARGET}
369                PACKAGE_SOURCES ${CMAKE_BINARY_DIR}/android-mobile DEPENDS ${ANDROID_NATIVE_LIBSSL} ${ANDROID_NATIVE_LIBCRYPT}
370        )
371elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
372        set(APP_BUNDLE_DIR "${SUBSURFACE_TARGET}.app")
373        if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
374                set(EXTRA_MACDEPLOY_ARGS "-qmldir=${APP_BUNDLE_DIR}/Contents/Frameworks/qml ")
375        endif()
376        set(MACDEPLOY_ARGS "${EXTRA_MACDEPLOY_ARGS}-executable=${APP_BUNDLE_DIR}/Contents/MacOS/${SUBSURFACE_TARGET} -always-overwrite")
377        set(RESOURCEDIR ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Resources)
378        set(PLUGINDIR ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/PlugIns)
379        install(DIRECTORY marbledata/maps DESTINATION ${RESOURCEDIR}/data)
380        install(DIRECTORY marbledata/bitmaps DESTINATION ${RESOURCEDIR}/data)
381        install(DIRECTORY Documentation/images DESTINATION ${RESOURCEDIR}/share/Documentation)
382        install(FILES ${DOCFILES} DESTINATION ${RESOURCEDIR}/share/Documentation)
383        install(DIRECTORY theme DESTINATION ${RESOURCEDIR})
384        install(DIRECTORY printing_templates DESTINATION ${RESOURCEDIR})
385        install(FILES ${TRANSLATIONS} DESTINATION ${RESOURCEDIR}/translations)
386        install(FILES ${QTTRANSLATIONS} DESTINATION ${RESOURCEDIR}/translations)
387        install(FILES ${CMAKE_SOURCE_DIR}/gpl-2.0.txt DESTINATION ${RESOURCEDIR})
388        # this is a HACK
389        if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
390                install(DIRECTORY ${Grantlee5_DIR}/../../grantlee DESTINATION ${PLUGINDIR})
391        endif()
392        # this is a hack - but I don't know how else to find the macdeployqt program if it's not in the PATH
393        string(REPLACE moc macdeployqt MACDEPLOYQT ${QT_MOC_EXECUTABLE})
394        install(CODE "execute_process(COMMAND ${MACDEPLOYQT} ${APP_BUNDLE_DIR} ${MACDEPLOY_ARGS})")
395        # and another hack to get the QML Components in the right place
396        if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
397                install(CODE "execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/qml)")
398                install(CODE "execute_process(COMMAND cp -a ${_qt5Core_install_prefix}/qml/QtQuick ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/qml)")
399        endif()
400        if(NOT NO_MARBLE)
401                # more hackery - this time for QtXml which is needed by libssrfmarblewidget
402                install(CODE "execute_process(COMMAND cp -a ${_qt5Core_install_prefix}/lib/QtXml.framework ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks)")
403                install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/Versions/5/Headers)")
404                install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/Headers)")
405                install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/QtXml.prl)")
406                install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/Versions/5/QtXml_debug)")
407                install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/QtXml_debug)")
408                install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/QtXml_debug.prl)")
409                install(CODE "execute_process(COMMAND install_name_tool -id @executable_path/../Frameworks/QtXml ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/QtXml)")
410                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)")
411        endif()
412        install(CODE "message(STATUS \"two ERRORS here about libmysqlclient and libpq not found are harmless\")")
413elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
414        # Windows bundling rules
415        # We don't have a helpful tool like macdeployqt for Windows, so we hardcode
416        # which libs we need.
417        # "make install", copies everything into a staging area
418        # "make installer", uses makensis to create an installer executable
419        set(WINDOWSSTAGING ${CMAKE_BINARY_DIR}/staging)
420        install(DIRECTORY marbledata/maps DESTINATION ${WINDOWSSTAGING}/data)
421        install(DIRECTORY marbledata/bitmaps DESTINATION ${WINDOWSSTAGING}/data)
422        install(DIRECTORY Documentation/images DESTINATION ${WINDOWSSTAGING}/Documentation)
423        install(FILES ${DOCFILES} DESTINATION ${WINDOWSSTAGING}/Documentation)
424        install(DIRECTORY theme DESTINATION ${WINDOWSSTAGING})
425        install(DIRECTORY printing_templates DESTINATION ${WINDOWSSTAGING})
426        install(FILES ${TRANSLATIONS} DESTINATION ${WINDOWSSTAGING}/translations)
427        install(FILES ${QTTRANSLATIONS} DESTINATION ${WINDOWSSTAGING}/translations)
428        install(FILES ${CMAKE_SOURCE_DIR}/gpl-2.0.txt ${CMAKE_SOURCE_DIR}/packaging/windows/subsurface.ico DESTINATION ${WINDOWSSTAGING})
429        install(TARGETS ${SUBSURFACE_TARGET} DESTINATION ${WINDOWSSTAGING})
430        install(FILES ${CMAKE_BINARY_DIR}/qt.conf DESTINATION ${WINDOWSSTAGING})
431        install(DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/grantlee DESTINATION ${WINDOWSSTAGING})
432        if(NOT DEFINED MAKENSIS)
433                set(MAKENSIS makensis)
434        endif()
435
436        # the script we created above is now added as a command to run at
437        # install time - so this ensures that subsurface.exe has been
438        # built before this is run
439        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)")
440
441        # create the subsurface-x.y.z.exe installer - this needs to depend
442        # on the install target but cmake doesn't allow that, so we depend
443        # on the fake target instead
444        add_custom_target(
445                fake_install
446                COMMAND "${CMAKE_COMMAND}" --build . --target install
447                DEPENDS ${SUBSURFACE_TARGET}
448        )
449
450        add_custom_target(
451                installer
452                COMMAND ${MAKENSIS} ${WINDOWSSTAGING}/subsurface.nsi
453                DEPENDS fake_install
454        )
455elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
456        install(DIRECTORY marbledata/maps DESTINATION share/subsurface/data)
457        install(DIRECTORY marbledata/bitmaps DESTINATION share/subsurface/data)
458        install(FILES subsurface.debug DESTINATION bin)
459        install(FILES subsurface.desktop DESTINATION share/applications)
460        install(FILES icons/subsurface-icon.svg DESTINATION share/icons/hicolor/scalable/apps)
461        install(DIRECTORY Documentation/images DESTINATION share/subsurface/Documentation)
462        install(FILES ${DOCFILES} DESTINATION share/subsurface/Documentation)
463        install(DIRECTORY theme DESTINATION share/subsurface)
464        install(DIRECTORY printing_templates DESTINATION share/subsurface)
465        install(FILES ${TRANSLATIONS} DESTINATION share/subsurface/translations)
466        install(TARGETS ${SUBSURFACE_TARGET} DESTINATION bin)
467        if (SMARTTRAK_IMPORT)
468                install(TARGETS ${SMTK_IMPORT_TARGET} DESTINATION bin)
469        endif()
470        if(DEFINED LIBMARBLEDEVEL)
471                install(
472                        CODE "file(GLOB SSRFMARBLE_SHLIBS \"${LIBMARBLEDEVEL}/lib/libssrfmarblewidget.so*\")"
473                        CODE "file(INSTALL \${SSRFMARBLE_SHLIBS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)"
474                )
475        endif()
476endif()
477
478if (MAKE_TESTS)
479        add_subdirectory(tests)
480endif()
481
482# useful for debugging CMake issues
483# print_all_variables()
Note: See TracBrowser for help on using the repository browser.