2015-03-26 20:50:28 +00:00
# cmake based build of Subsurface
2016-03-16 07:57:41 +00:00
# Uncomment his to see all commands cmake actually executes
# set(CMAKE_VERBOSE_MAKEFILE ON)
2014-04-14 17:21:01 +00:00
project(Subsurface)
2015-02-02 15:52:35 +00:00
cmake_minimum_required(VERSION 2.8.11)
2014-04-14 19:47:12 +00:00
2015-03-26 20:50:28 +00:00
# global settings
2015-04-18 12:22:11 +00:00
set(CMAKE_AUTOMOC ON)
2015-11-17 19:08:42 +00:00
include(cmake/Modules/MacroOutOfSourceBuild.cmake)
MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
"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."
)
2015-11-09 20:57:47 +00:00
2015-11-17 21:16:51 +00:00
#Options regarding usage of pkgconfig
2015-04-18 12:22:11 +00:00
option(LIBGIT2_FROM_PKGCONFIG "use pkg-config to retrieve libgit2" OFF)
option(LIBDC_FROM_PKGCONFIG "use pkg-config to retrieve libdivecomputer" OFF)
2015-05-26 10:51:49 +00:00
option(LIBGRANTLEE_FROM_PKGCONFIG "use pkg-config to retrieve grantlee" OFF)
2015-09-22 11:45:40 +00:00
option(LIBMARBLE_FROM_PKGCONFIG "use pkg-config to retrieve marble" OFF)
2015-11-17 18:48:17 +00:00
2015-11-17 21:16:51 +00:00
#Library Handling
option(FORCE_LIBSSH "force linking with libssh to workaround libgit2 bug" ON)
2017-01-16 23:56:56 +00:00
option(LIBGIT2_DYNAMIC "search for libgit2.so before libgit2.a" OFF)
2015-11-17 21:16:51 +00:00
#Options regarding disabling parts of subsurface.
2015-04-18 12:22:11 +00:00
option(NO_MARBLE "disable the marble widget" OFF)
option(NO_DOCS "disable the docs" OFF)
2015-09-01 16:49:57 +00:00
option(NO_PRINTING "disable the printing support" OFF)
2015-07-01 15:08:33 +00:00
option(NO_USERMANUAL "don't include a viewer for the user manual" OFF)
2015-11-17 21:16:51 +00:00
#Options regarding enabling parts of subsurface
2015-07-06 19:11:07 +00:00
option(FBSUPPORT "allow posting to Facebook" ON)
2015-07-20 16:35:00 +00:00
option(BTSUPPORT "enable support for QtBluetooth (requires Qt5.4 or newer)" ON)
2015-08-20 22:19:45 +00:00
option(FTDISUPPORT "enable support for libftdi based serial" OFF)
2016-08-08 22:12:12 +00:00
option(USE_WEBENGINE "Use QWebEngine instead of QWebKit" OFF)
2015-11-17 21:16:51 +00:00
# Options regarding What should we build on subsurface
option(MAKE_TESTS "Make the tests" ON)
2015-12-16 16:30:56 +00:00
#Extra features
option(SMARTTRAK_IMPORT "enable building SmartTrak divelogs import tool (requires glib2 and libmdb)" OFF)
2015-11-17 21:16:51 +00:00
2015-11-23 14:34:14 +00:00
SET(SUBSURFACE_TARGET_EXECUTABLE "DesktopExecutable" CACHE STRING "The type of application, DesktopExecutable or MobileExecutable")
LIST(APPEND SUBSURFACE_ACCEPTED_EXECUTABLES "DesktopExecutable" "MobileExecutable")
2015-12-16 17:09:32 +00:00
SET_PROPERTY(CACHE SUBSURFACE_TARGET_EXECUTABLE PROPERTY STRINGS ${SUBSURFACE_ACCEPTED_EXECUTABLES})
2015-11-23 14:34:14 +00:00
2015-11-23 14:13:24 +00:00
#verify if Platform is correct and warn on wxit with example.
2015-12-16 16:30:56 +00:00
list (FIND SUBSURFACE_ACCEPTED_EXECUTABLES ${SUBSURFACE_TARGET_EXECUTABLE} _index)
2015-11-23 14:13:24 +00:00
if (${_index} EQUAL -1)
message(FATAL_ERROR "Requested platform not supported, please use one of the following:
2015-12-16 16:30:56 +00:00
${SUBSURFACE_ACCEPTED_EXECUTABLES}
2015-11-23 14:13:24 +00:00
2015-12-16 16:30:56 +00:00
inputted value was: ${SUBSURFACE_TARGET_EXECUTABLE}
2015-11-23 14:13:24 +00:00
2015-12-16 17:48:20 +00:00
Example: -DSUBSURFACE_TARGET_EXECUTABLE=DesktopExecutable")
2015-12-01 19:46:59 +00:00
endif()
2015-09-02 23:52:34 +00:00
add_definitions(-DSUBSURFACE_SOURCE="${CMAKE_SOURCE_DIR}")
2015-11-23 14:13:24 +00:00
#evenrything's correct, moving on.
2015-06-04 03:10:40 +00:00
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${${PROJECT_NAME}_SOURCE_DIR}/cmake/Modules
)
2015-11-17 19:21:42 +00:00
#
# TODO: This Compilation part should go on the Target specific CMake.
#
2015-11-09 00:33:19 +00:00
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
2015-11-09 00:01:05 +00:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 ")
2017-01-01 18:31:47 +00:00
if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND
((${CMAKE_SYSTEM_VERSION} MATCHES "11.4.") OR
(${CMAKE_OSX_DEPLOYMENT_TARGET} MATCHES "10.7") OR
(${CMAKE_OSX_DEPLOYMENT_TARGET} MATCHES "10.8")))
2017-01-01 05:17:02 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
2015-11-09 00:33:19 +00:00
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
2015-11-09 00:01:05 +00:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 ")
2016-06-23 20:56:26 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
2015-11-09 00:33:19 +00:00
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
2015-11-09 00:01:05 +00:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
2016-06-23 20:56:26 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
2015-11-09 00:33:19 +00:00
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# using Intel C++
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# using Visual Studio C++
2014-04-14 17:21:01 +00:00
endif()
2015-03-26 20:50:28 +00:00
# pkgconfig for required libraries
2015-04-18 12:22:11 +00:00
find_package(PkgConfig)
include(cmake/Modules/pkgconfig_helper.cmake)
2015-11-17 19:21:42 +00:00
# The 'HandleFindXXX' are special libraries that subsurface needs
# to find and configure in a few different ways because of a few
# developers that prefer pkg-config over CMake, so we try to make
# everyone happy. It also sets some variables for each library, so
# if you think a module miss anything, take a look on the specific
# module file.
2015-11-17 18:48:17 +00:00
include(cmake/Modules/HandleFindGit2.cmake)
2015-11-17 19:52:49 +00:00
include(cmake/Modules/HandleFindLibDiveComputer.cmake)
2015-12-30 17:55:24 +00:00
if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
include(cmake/Modules/HandleFindMarble.cmake)
include(cmake/Modules/HandleFindGrantlee.cmake)
include(cmake/Modules/HandleUserManual.cmake)
endif()
2015-11-17 20:23:32 +00:00
include(cmake/Modules/HandleFtdiSupport.cmake)
2015-11-17 20:33:33 +00:00
include(cmake/Modules/HandleVersionGeneration.cmake)
2015-11-23 14:39:07 +00:00
include(cmake/Modules/RunOnBuildDir.cmake)
2015-11-17 20:23:32 +00:00
2015-04-10 19:08:26 +00:00
pkg_config_library(LIBXML libxml-2.0 REQUIRED)
pkg_config_library(LIBSQLITE3 sqlite3 REQUIRED)
pkg_config_library(LIBXSLT libxslt REQUIRED)
pkg_config_library(LIBZIP libzip REQUIRED)
pkg_config_library(LIBUSB libusb-1.0 QUIET)
2015-03-26 20:50:28 +00:00
2015-11-10 19:51:40 +00:00
if(SMARTTRAK_IMPORT)
pkg_config_library(GLIB2 glib-2.0 REQUIRED)
pkg_config_library(LIBMDB libmdb REQUIRED)
endif()
2015-11-17 21:22:02 +00:00
include_directories(.
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/desktop-widgets
)
2015-11-23 14:19:38 +00:00
# Project Target specific configuration should go here,
# if the configuration is too big or would disrupt the normal code flux,
# move it somewhere else (another file) and include it.
2015-12-16 17:48:20 +00:00
if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
2015-12-17 19:08:21 +00:00
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(SUBSURFACE_TARGET Subsurface)
else()
set(SUBSURFACE_TARGET subsurface)
endif()
2016-01-07 16:38:16 +00:00
remove_definitions(-DSUBSURFACE_MOBILE)
2015-12-16 18:41:28 +00:00
elseif(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
2015-12-17 19:08:21 +00:00
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(SUBSURFACE_TARGET Subsurface-mobile)
else()
set(SUBSURFACE_TARGET subsurface-mobile)
endif()
list(APPEND QT_EXTRA_COMPONENTS Quick)
list(APPEND QT_EXTRA_LIBRARIES Qt5::Quick)
add_definitions(-DSUBSURFACE_MOBILE)
2015-12-16 16:50:41 +00:00
endif()
if(ANDROID)
set(NO_PRINTING ON)
list(APPEND QT_EXTRA_COMPONENTS AndroidExtras)
list(APPEND QT_EXTRA_LIBRARIES Qt5::AndroidExtras)
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -llog)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
2015-12-16 16:33:52 +00:00
# add pthread to the end of the library list on Linux
# this is only needed on Ubuntu
# but shouldn't hurt on other Linux versions
# in some builds we appear to be missing libz for some strange reason...
2016-07-21 10:55:23 +00:00
# Add ssh2 at the end for openSUSE builds (for recent cmake?)
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lssh2 -lz -lpthread)
2015-12-16 16:33:52 +00:00
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
execute_process(
COMMAND sh scripts/get-version linux
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE SSRF_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
)
find_library(APP_SERVICES_LIBRARY ApplicationServices)
find_library(HID_LIB HidApi)
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${HID_LIB})
set(EXTRA_LIBS ${APP_SERVICES_LIBRARY})
set(ICON_FILE ${CMAKE_SOURCE_DIR}/packaging/macosx/Subsurface.icns)
2015-12-16 22:34:33 +00:00
if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
set(MACOSX_BUNDLE_INFO_STRING "Subsurface-mobile")
set(MACOSX_BUNDLE_BUNDLE_NAME "Subsurface-mobile")
else()
set(MACOSX_BUNDLE_INFO_STRING "Subsurface")
set(MACOSX_BUNDLE_BUNDLE_NAME "Subsurface")
endif()
2015-12-17 16:28:43 +00:00
set(MACOSX_BUNDLE_ICON_FILE Subsurface.icns)
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.subsurface-divelog")
2015-12-16 16:33:52 +00:00
set(MACOSX_BUNDLE_BUNDLE_VERSION "${SSRF_VERSION_STRING}")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${SSRF_VERSION_STRING}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${SSRF_VERSION_STRING}")
set(MACOSX_BUNDLE_COPYRIGHT "Linus Torvalds, Dirk Hohndel, Tomaz Canabrava, and others")
set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set(SUBSURFACE_PKG MACOSX_BUNDLE ${ICON_FILE})
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lwsock32 -lws2_32)
remove_definitions(-DUNICODE)
add_definitions(-mwindows -D_WIN32)
2015-07-01 15:08:36 +00:00
endif()
2015-11-23 14:13:24 +00:00
2015-10-26 13:05:27 +00:00
if(BTSUPPORT)
2015-11-20 13:49:56 +00:00
list(APPEND QT_EXTRA_COMPONENTS Bluetooth)
list(APPEND QT_EXTRA_LIBRARIES Qt5::Bluetooth)
2015-10-26 13:05:27 +00:00
endif()
2015-11-20 13:49:56 +00:00
2015-11-23 14:13:24 +00:00
find_package(Qt5 REQUIRED COMPONENTS Core Concurrent Widgets Network Svg Test LinguistTools Positioning ${QT_EXTRA_COMPONENTS})
2015-11-20 13:49:56 +00:00
set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network Qt5::Svg Qt5::Positioning ${QT_EXTRA_LIBRARIES})
2015-04-18 12:22:11 +00:00
set(QT_TEST_LIBRARIES ${QT_LIBRARIES} Qt5::Test)
2015-02-02 15:52:35 +00:00
2015-11-23 14:13:24 +00:00
#disable bluetooth if Qt version is ancient.
2015-10-26 13:05:27 +00:00
if (BTSUPPORT AND "${Qt5Core_VERSION_STRING}" STRLESS "5.4.0")
2015-07-20 16:35:00 +00:00
set(BTSUPPORT OFF)
2015-11-03 17:20:47 +00:00
message(STATUS "Turning off Bluetooth support as Qt version ${Qt5Core_VERSION_STRING} is insufficient for that")
2015-10-26 21:51:07 +00:00
list(REMOVE_ITEM QT_LIBRARIES Qt5::Bluetooth)
2015-07-20 16:35:00 +00:00
endif()
2016-01-02 12:26:23 +00:00
if(BTSUPPORT)
add_definitions(-DBT_SUPPORT)
endif()
2015-11-23 14:13:24 +00:00
#set up the subsurface_link_libraries variable
2015-11-20 13:49:56 +00:00
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${LIBDIVECOMPUTER_LIBRARIES} ${LIBGIT2_LIBRARIES} ${LIBUSB_LIBRARIES})
2015-09-17 22:24:26 +00:00
qt5_add_resources(SUBSURFACE_RESOURCES subsurface.qrc)
2015-04-09 18:50:06 +00:00
# include translations
add_subdirectory(translations)
2016-04-05 05:02:03 +00:00
add_subdirectory(core)
2015-09-03 18:25:01 +00:00
add_subdirectory(qt-models)
2015-09-03 18:56:37 +00:00
add_subdirectory(profile-widget)
2015-11-05 23:06:10 +00:00
2015-11-10 19:51:40 +00:00
if(SMARTTRAK_IMPORT)
add_subdirectory(smtk-import)
endif()
2015-12-16 17:48:20 +00:00
if (${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
2015-11-05 23:06:10 +00:00
add_subdirectory(desktop-widgets)
endif()
2014-04-14 17:21:01 +00:00
2015-03-26 20:50:28 +00:00
# create the executables
2015-12-16 17:48:20 +00:00
if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
2015-09-03 17:49:59 +00:00
set(MOBILE_SRC
2016-04-05 05:02:03 +00:00
mobile-widgets/qmlmanager.cpp
mobile-widgets/qmlprofile.cpp
2016-08-19 04:38:13 +00:00
mobile-widgets/qml/kirigami/src/kirigamiplugin.cpp
mobile-widgets/qml/kirigami/src/enums.cpp
2015-11-06 21:44:13 +00:00
subsurface-mobile-main.cpp
subsurface-mobile-helper.cpp
2015-09-03 17:49:59 +00:00
)
2017-01-23 00:59:11 +00:00
if(NOT ANDROID AND NOT iOS)
set(MOBILE_SRC ${MOBILE_SRC} mobile-widgets/qml/kirigami/src/desktopicon.cpp)
endif()
2016-08-19 04:38:13 +00:00
add_definitions(-DKIRIGAMI_BUILD_TYPE_STATIC)
2016-04-05 05:02:03 +00:00
qt5_add_resources(MOBILE_RESOURCES mobile-widgets/qml/mobile-resources.qrc)
2016-08-19 04:38:13 +00:00
qt5_add_resources(MOBILE_RESOURCES mobile-widgets/qml/kirigami/kirigami.qrc)
2015-12-16 16:55:53 +00:00
# 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.
if(ANDROID)
2015-12-16 16:57:32 +00:00
add_library(${SUBSURFACE_TARGET} SHARED ${SUBSURFACE_PKG} ${MOBILE_SRC} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES})
2015-07-09 22:02:35 +00:00
else()
2015-12-16 16:57:32 +00:00
add_executable(${SUBSURFACE_TARGET} MACOSX_BUNDLE WIN32 ${SUBSURFACE_PKG} ${MOBILE_SRC} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES})
2015-07-09 22:02:35 +00:00
endif()
2015-05-27 12:33:23 +00:00
target_link_libraries(
2015-11-05 23:06:10 +00:00
${SUBSURFACE_TARGET}
subsurface_profile
subsurface_models
subsurface_corelib
2015-11-23 14:34:14 +00:00
${SUBSURFACE_LINK_LIBRARIES}
)
2015-12-16 17:48:20 +00:00
elseif(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
2015-11-05 23:06:10 +00:00
set(SUBSURFACE_APP
subsurface-desktop-main.cpp
subsurface-desktop-helper.cpp
)
source_group("Subsurface App" FILES ${SUBSURFACE_APP})
2015-12-16 16:57:32 +00:00
if(ANDROID)
2015-12-17 16:33:05 +00:00
add_library(${SUBSURFACE_TARGET} SHARED ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES})
2015-12-16 16:57:32 +00:00
else()
add_executable(${SUBSURFACE_TARGET} MACOSX_BUNDLE WIN32 ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES})
endif()
2015-11-05 23:06:10 +00:00
2015-12-16 16:57:32 +00:00
if(SMARTTRAK_IMPORT)
2015-11-10 19:51:40 +00:00
set(SMTK_IMPORT_TARGET smtk2ssrf)
add_executable(smtk2ssrf smtk-import/smtk_standalone.cpp ${SUBSURFACE_RESOURCES})
target_link_libraries(smtk2ssrf smtk_import)
endif()
2016-09-23 00:12:00 +00:00
if(FBSUPPORT)
set(FACEBOOK_INTEGRATION facebook_integration)
endif()
2015-11-05 23:06:10 +00:00
target_link_libraries(
${SUBSURFACE_TARGET}
2015-05-27 12:33:23 +00:00
subsurface_generated_ui
subsurface_interface
2015-12-01 19:46:59 +00:00
${FACEBOOK_INTEGRATION}
2015-05-27 12:33:23 +00:00
subsurface_profile
subsurface_statistics
subsurface_models
subsurface_corelib
2015-11-05 23:06:10 +00:00
${SUBSURFACE_LINK_LIBRARIES}
)
add_dependencies(subsurface_statistics subsurface_generated_ui)
add_dependencies(subsurface_interface subsurface_generated_ui)
add_dependencies(subsurface_profile subsurface_generated_ui)
2017-01-03 15:06:33 +00:00
add_dependencies(subsurface_models subsurface_generated_ui)
2015-11-05 23:06:10 +00:00
add_dependencies(subsurface_generated_ui version)
2015-05-27 12:33:23 +00:00
endif()
2014-04-14 17:21:01 +00:00
2015-04-18 12:22:11 +00:00
add_dependencies(subsurface_corelib version)
2014-04-14 17:21:01 +00:00
2015-03-31 21:03:02 +00:00
# add platform specific actions
2015-04-18 12:22:11 +00:00
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_custom_command(
2015-03-31 21:03:02 +00:00
OUTPUT ${CMAKE_BINARY_DIR}/qt.conf
COMMAND echo \"[Paths]\" > ${CMAKE_BINARY_DIR}/qt.conf \; echo \"Prefix=.\" >> ${CMAKE_BINARY_DIR}/qt.conf
2015-04-18 12:22:14 +00:00
)
2015-04-18 12:22:11 +00:00
add_custom_target(
2015-03-31 21:03:02 +00:00
generate_qtconf
DEPENDS ${CMAKE_BINARY_DIR}/qt.conf
2015-04-18 12:22:14 +00:00
)
2015-04-18 12:22:11 +00:00
add_dependencies(${SUBSURFACE_TARGET} generate_qtconf)
endif()
2015-03-31 21:03:02 +00:00
2015-06-16 13:58:22 +00:00
# build an automated html exporter
2015-09-02 23:52:34 +00:00
add_executable(export-html EXCLUDE_FROM_ALL export-html.cpp ${SUBSURFACE_RESOURCES})
2015-06-16 13:58:22 +00:00
target_link_libraries(export-html subsurface_corelib ${SUBSURFACE_LINK_LIBRARIES})
2015-03-30 19:50:52 +00:00
# install Subsurface
# first some variables with files that need installing
set(DOCFILES
README
ReleaseNotes/ReleaseNotes.txt
2015-03-30 21:43:15 +00:00
SupportedDivecomputers.txt
${CMAKE_BINARY_DIR}/Documentation/user-manual.html
${CMAKE_BINARY_DIR}/Documentation/user-manual_es.html
${CMAKE_BINARY_DIR}/Documentation/user-manual_fr.html
${CMAKE_BINARY_DIR}/Documentation/user-manual_ru.html
2015-03-30 19:50:52 +00:00
)
2017-02-03 18:57:57 +00:00
# add all the translations that we may need
2015-12-16 22:24:47 +00:00
FILE(STRINGS "subsurface_enabled_translations" QTTRANSLATIONS_BASE)
2015-03-31 20:39:09 +00:00
2015-04-10 19:10:07 +00:00
if(NOT DEFINED QT_TRANSLATION_DIR OR QT_TRANSLATION_DIR STREQUAL "")
2015-04-04 23:21:32 +00:00
set(QT_TRANSLATION_DIR ${Qt5Core_DIR}/../../../translations)
endif()
2015-04-04 20:12:20 +00:00
set(QTTRANSLATIONS "")
2015-03-31 20:39:09 +00:00
foreach(QTTRANSLATION ${QTTRANSLATIONS_BASE})
2015-04-04 20:12:20 +00:00
if(NOT ${QTTRANSLATION} STREQUAL "")
2017-02-03 18:57:57 +00:00
if(EXISTS ${QT_TRANSLATION_DIR}/${QTTRANSLATION})
set(QTTRANSLATIONS ${QTTRANSLATIONS} ${QT_TRANSLATION_DIR}/${QTTRANSLATION})
endif()
2015-04-04 20:12:20 +00:00
endif()
2015-03-31 20:39:09 +00:00
endforeach()
2015-03-30 19:50:52 +00:00
# now for each platform the install instructions
2015-12-16 22:25:38 +00:00
if(ANDROID)
2015-04-18 12:22:09 +00:00
# Android template directory
2015-07-08 22:42:12 +00:00
include(${QT_ANDROID_CMAKE})
2015-12-17 19:09:23 +00:00
add_qt_android_apk(${SUBSURFACE_TARGET}.apk ${SUBSURFACE_TARGET}
2016-08-29 02:16:05 +00:00
PACKAGE_SOURCES ${CMAKE_BINARY_DIR}/android-mobile DEPENDS ${ANDROID_NATIVE_LIBSSL} ${ANDROID_NATIVE_LIBCRYPT}
2015-11-23 14:48:35 +00:00
)
2015-12-16 22:25:38 +00:00
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
2015-12-17 19:09:23 +00:00
set(APP_BUNDLE_DIR "${SUBSURFACE_TARGET}.app")
2015-12-16 22:34:33 +00:00
if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
2015-12-17 19:09:23 +00:00
set(EXTRA_MACDEPLOY_ARGS "-qmldir=${APP_BUNDLE_DIR}/Contents/Frameworks/qml ")
2015-12-16 22:34:33 +00:00
endif()
2015-12-17 19:09:23 +00:00
set(MACDEPLOY_ARGS "${EXTRA_MACDEPLOY_ARGS}-executable=${APP_BUNDLE_DIR}/Contents/MacOS/${SUBSURFACE_TARGET} -always-overwrite")
2015-12-16 22:34:33 +00:00
set(RESOURCEDIR ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Resources)
set(PLUGINDIR ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/PlugIns)
2015-12-16 22:27:27 +00:00
install(DIRECTORY marbledata/maps DESTINATION ${RESOURCEDIR}/data)
install(DIRECTORY marbledata/bitmaps DESTINATION ${RESOURCEDIR}/data)
install(DIRECTORY Documentation/images DESTINATION ${RESOURCEDIR}/share/Documentation)
install(FILES ${DOCFILES} DESTINATION ${RESOURCEDIR}/share/Documentation)
install(DIRECTORY theme DESTINATION ${RESOURCEDIR})
install(DIRECTORY printing_templates DESTINATION ${RESOURCEDIR})
install(FILES ${TRANSLATIONS} DESTINATION ${RESOURCEDIR}/translations)
install(FILES ${QTTRANSLATIONS} DESTINATION ${RESOURCEDIR}/translations)
install(FILES ${CMAKE_SOURCE_DIR}/gpl-2.0.txt DESTINATION ${RESOURCEDIR})
# this is a HACK
2016-01-07 18:22:31 +00:00
if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable")
install(DIRECTORY ${Grantlee5_DIR}/../../grantlee DESTINATION ${PLUGINDIR})
endif()
2015-12-16 22:27:27 +00:00
# this is a hack - but I don't know how else to find the macdeployqt program if it's not in the PATH
string(REPLACE moc macdeployqt MACDEPLOYQT ${QT_MOC_EXECUTABLE})
2015-12-16 22:34:33 +00:00
install(CODE "execute_process(COMMAND ${MACDEPLOYQT} ${APP_BUNDLE_DIR} ${MACDEPLOY_ARGS})")
# and another hack to get the QML Components in the right place
if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable")
install(CODE "execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/qml)")
install(CODE "execute_process(COMMAND cp -a ${_qt5Core_install_prefix}/qml/QtQuick ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/qml)")
endif()
if(NOT NO_MARBLE)
# more hackery - this time for QtXml which is needed by libssrfmarblewidget
install(CODE "execute_process(COMMAND cp -a ${_qt5Core_install_prefix}/lib/QtXml.framework ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks)")
install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/Versions/5/Headers)")
install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/Headers)")
install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/QtXml.prl)")
2015-12-17 23:24:01 +00:00
install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/Versions/5/QtXml_debug)")
install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/QtXml_debug)")
install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/QtXml_debug.prl)")
2015-12-16 22:34:33 +00:00
install(CODE "execute_process(COMMAND install_name_tool -id @executable_path/../Frameworks/QtXml ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/QtXml)")
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)")
endif()
2015-12-16 22:27:27 +00:00
install(CODE "message(STATUS \"two ERRORS here about libmysqlclient and libpq not found are harmless\")")
2015-12-16 22:25:38 +00:00
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
2015-12-16 22:27:27 +00:00
# Windows bundling rules
# We don't have a helpful tool like macdeployqt for Windows, so we hardcode
# which libs we need.
# "make install", copies everything into a staging area
# "make installer", uses makensis to create an installer executable
set(WINDOWSSTAGING ${CMAKE_BINARY_DIR}/staging)
install(DIRECTORY marbledata/maps DESTINATION ${WINDOWSSTAGING}/data)
install(DIRECTORY marbledata/bitmaps DESTINATION ${WINDOWSSTAGING}/data)
install(DIRECTORY Documentation/images DESTINATION ${WINDOWSSTAGING}/Documentation)
install(FILES ${DOCFILES} DESTINATION ${WINDOWSSTAGING}/Documentation)
install(DIRECTORY theme DESTINATION ${WINDOWSSTAGING})
install(DIRECTORY printing_templates DESTINATION ${WINDOWSSTAGING})
install(FILES ${TRANSLATIONS} DESTINATION ${WINDOWSSTAGING}/translations)
install(FILES ${QTTRANSLATIONS} DESTINATION ${WINDOWSSTAGING}/translations)
install(FILES ${CMAKE_SOURCE_DIR}/gpl-2.0.txt ${CMAKE_SOURCE_DIR}/packaging/windows/subsurface.ico DESTINATION ${WINDOWSSTAGING})
install(TARGETS ${SUBSURFACE_TARGET} DESTINATION ${WINDOWSSTAGING})
install(FILES ${CMAKE_BINARY_DIR}/qt.conf DESTINATION ${WINDOWSSTAGING})
install(DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/grantlee DESTINATION ${WINDOWSSTAGING})
if(NOT DEFINED MAKENSIS)
set(MAKENSIS makensis)
endif()
2015-11-23 14:48:35 +00:00
2015-12-16 22:27:27 +00:00
# the script we created above is now added as a command to run at
# install time - so this ensures that subsurface.exe has been
# built before this is run
2015-12-17 23:50:10 +00:00
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DSUBSURFACE_TARGET=${SUBSURFACE_TARGET} -DSUBSURFACE_SOURCE=${CMAKE_SOURCE_DIR} -DSTAGING=${WINDOWSSTAGING} -P ${CMAKE_SOURCE_DIR}/cmake/Modules/dlllist.cmake)")
2015-03-30 19:50:52 +00:00
2015-12-16 22:27:27 +00:00
# create the subsurface-x.y.z.exe installer - this needs to depend
# on the install target but cmake doesn't allow that, so we depend
# on the fake target instead
add_custom_target(
fake_install
COMMAND "${CMAKE_COMMAND}" --build . --target install
DEPENDS ${SUBSURFACE_TARGET}
)
add_custom_target(
installer
COMMAND ${MAKENSIS} ${WINDOWSSTAGING}/subsurface.nsi
DEPENDS fake_install
)
2015-12-16 22:25:38 +00:00
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
2015-12-16 22:27:27 +00:00
install(DIRECTORY marbledata/maps DESTINATION share/subsurface/data)
install(DIRECTORY marbledata/bitmaps DESTINATION share/subsurface/data)
install(FILES subsurface.debug DESTINATION bin)
install(FILES subsurface.desktop DESTINATION share/applications)
install(FILES icons/subsurface-icon.svg DESTINATION share/icons/hicolor/scalable/apps)
install(DIRECTORY Documentation/images DESTINATION share/subsurface/Documentation)
install(FILES ${DOCFILES} DESTINATION share/subsurface/Documentation)
install(DIRECTORY theme DESTINATION share/subsurface)
install(DIRECTORY printing_templates DESTINATION share/subsurface)
install(FILES ${TRANSLATIONS} DESTINATION share/subsurface/translations)
2016-01-07 16:38:16 +00:00
install(TARGETS ${SUBSURFACE_TARGET} DESTINATION bin)
if (SMARTTRAK_IMPORT)
install(TARGETS ${SMTK_IMPORT_TARGET} DESTINATION bin)
endif()
2015-12-16 22:27:27 +00:00
if(DEFINED LIBMARBLEDEVEL)
install(
CODE "file(GLOB SSRFMARBLE_SHLIBS \"${LIBMARBLEDEVEL}/lib/libssrfmarblewidget.so*\")"
CODE "file(INSTALL \${SSRFMARBLE_SHLIBS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)"
)
endif()
2015-04-18 12:22:11 +00:00
endif()
2015-09-03 20:10:50 +00:00
if (MAKE_TESTS)
add_subdirectory(tests)
endif()
2016-09-23 00:12:49 +00:00
# useful for debugging CMake issues
#
# message(STATUS "print variables")
# get_cmake_property(_variableNames VARIABLES)
# foreach(_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
# endforeach()