source: subsurface/CMakeLists.txt

Last change on this file was 5be38b2, checked in by Dirk Hohndel <dirk@…>, 5 days ago

cmake: building Subsurface-mobile without BT is no longer supported

It just doesn't seem to make sense. Why would you do that.
Allowing this options makes things more complicated as we need to
test for that in various places.

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

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