2015-03-26 20:50:28 +00:00
# cmake based build of Subsurface
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-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-09-03 20:10:50 +00:00
option(MAKE_TESTS "Make the tests" ON)
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-07-08 22:42:11 +00:00
option(FORCE_LIBSSH "force linking with libssh to workaround libgit2 bug" ON)
2015-06-21 12:56:36 +00:00
option(SUBSURFACE_MOBILE "build the QtQuick version for mobile device" OFF)
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)
2015-11-09 00:28:56 +00:00
option(DISABLE_PLUGINS "disable support for social media plugins" OFF)
2015-11-10 19:51:40 +00:00
option(SMARTTRAK_IMPORT "enable building SmartTrak divelogs import tool (requires glib2 and libmdb)" OFF)
2015-04-07 20:29:35 +00:00
2015-12-01 19:46:59 +00:00
if (NOT FBSUPPORT)
set(DISABLE_PLUGINS ON)
endif()
2015-09-02 23:52:34 +00:00
add_definitions(-DSUBSURFACE_SOURCE="${CMAKE_SOURCE_DIR}")
2015-06-04 03:10:40 +00:00
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${${PROJECT_NAME}_SOURCE_DIR}/cmake/Modules
)
2015-05-28 17:40:07 +00:00
include_directories(.
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_BINARY_DIR}
2015-09-03 17:20:19 +00:00
${CMAKE_BINARY_DIR}/desktop-widgets
desktop-widgets/
2015-05-28 17:40:07 +00:00
qt-models
2015-09-03 17:20:19 +00:00
desktop-widgets/profile
2015-09-02 23:52:34 +00:00
subsurface-core/
2015-05-28 17:40:07 +00:00
)
2015-03-26 20:50:28 +00:00
2015-08-17 15:43:35 +00:00
# get the version string -- this is only used for Mac Bundle at this point
# the other version data gets updated when running make - this is set when running cmake
execute_process(
COMMAND sh scripts/get-version linux
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE SSRF_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Creating build files for Subsurface ${SSRF_VERSION_STRING}")
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 ")
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 ")
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")
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-11-17 20:04:14 +00:00
include(cmake/Modules/HandleFindMarble.cmake)
2015-11-17 20:23:32 +00:00
include(cmake/Modules/HandleFindGrantlee.cmake)
include(cmake/Modules/HandleFtdiSupport.cmake)
2015-11-17 20:33:33 +00:00
include(cmake/Modules/HandleVersionGeneration.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 20:23:32 +00:00
if(ANDROID)
set(FBSUPPORT OFF)
set(NO_PRINTING ON)
2015-05-29 19:31:15 +00:00
endif()
2015-07-01 15:08:33 +00:00
if(NO_USERMANUAL)
message(STATUS "building without usermanual")
add_definitions(-DNO_USERMANUAL)
else()
set(WEBKIT_PKG WebKitWidgets)
set(WEBKIT_LIB Qt5::WebKitWidgets)
endif()
2015-11-05 19:54:08 +00:00
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${LIBDIVECOMPUTER_LIBRARIES} ${LIBGIT2_LIBRARIES} ${LIBUSB_LIBRARIES})
2014-04-14 17:21:01 +00:00
2015-04-18 12:22:09 +00:00
# configure Qt.
2015-05-27 12:33:23 +00:00
if(SUBSURFACE_MOBILE)
2015-07-01 15:08:34 +00:00
set(QT_QUICK_PKG Quick)
set(QT_QUICK_LIB Qt5::Quick)
2015-11-18 22:41:47 +00:00
add_definitions(-DSUBSURFACE_MOBILE)
2015-05-27 12:33:23 +00:00
endif()
2015-07-08 22:42:12 +00:00
if(ANDROID)
2015-07-01 15:08:36 +00:00
set(ANDROID_PKG AndroidExtras)
set(ANDROID_LIB Qt5::AndroidExtras)
endif()
2015-10-26 13:05:27 +00:00
if(BTSUPPORT)
set(BLUETOOTH_PKG Bluetooth)
set(BLUETOOTH_LIB Qt5::Bluetooth)
endif()
2015-11-19 02:30:55 +00:00
find_package(Qt5 REQUIRED COMPONENTS Core Concurrent Widgets Network ${WEBKIT_PKG} ${PRINTING_PKG} Svg Test LinguistTools ${QT_QUICK_PKG} ${ANDROID_PKG} Bluetooth Location)
set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network ${WEBKIT_LIB} ${PRINTING_LIB} Qt5::Svg ${QT_QUICK_LIB} ${ANDROID_LIB} Qt5::Bluetooth Qt5::Positioning)
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-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()
2015-11-08 18:08:41 +00:00
if(BTSUPPORT)
add_definitions(-DBT_SUPPORT)
endif()
2015-03-26 20:50:28 +00:00
# set up the different target platforms
2015-03-26 19:24:46 +00:00
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
2015-04-05 13:53:17 +00:00
set(SUBSURFACE_TARGET subsurface)
2015-04-06 00:41:35 +00:00
# in some builds we appear to be missing libz for some strange reason...
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lz)
2015-04-18 12:22:11 +00:00
endif()
2015-07-08 22:42:12 +00:00
if(ANDROID)
2015-07-01 15:08:36 +00:00
set(SUBSURFACE_TARGET subsurface)
2015-08-20 22:19:44 +00:00
# To allow us to debug log to logcat
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -llog)
2015-07-01 15:08:36 +00:00
endif()
2015-04-18 12:22:11 +00:00
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
2015-11-30 23:06:18 +00:00
if(SUBSURFACE_MOBILE)
set(SUBSURFACE_TARGET Subsurface-mobile)
set(MACOSX_BUNDLE_INFO_STRING "Subsurface-mobile")
set(MACOSX_BUNDLE_ICON_FILE Subsurface.icns)
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.subsurface-divelog")
set(MACOSX_BUNDLE_BUNDLE_NAME "Subsurface-mobile")
else()
set(SUBSURFACE_TARGET Subsurface)
set(MACOSX_BUNDLE_INFO_STRING "Subsurface")
set(MACOSX_BUNDLE_ICON_FILE Subsurface.icns)
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.subsurface-divelog")
set(MACOSX_BUNDLE_BUNDLE_NAME "Subsurface")
endif()
2015-12-15 06:34:15 +00:00
# on the Mac with Homebrew, libzip ends up with odd include dirs
include_directories(${LIBZIP_INCLUDE_DIRS})
2015-04-18 12:22:11 +00:00
find_library(APP_SERVICES_LIBRARY ApplicationServices)
2015-10-18 00:54:57 +00:00
find_library(HID_LIB HidApi)
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${HID_LIB})
2015-04-18 12:22:11 +00:00
set(EXTRA_LIBS ${APP_SERVICES_LIBRARY})
set(ICON_FILE ${CMAKE_SOURCE_DIR}/packaging/macosx/Subsurface.icns)
2015-08-17 15:43:35 +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}")
2015-04-18 12:22:11 +00:00
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})
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
2015-04-05 13:53:17 +00:00
set(SUBSURFACE_TARGET subsurface)
2015-08-21 17:02:27 +00:00
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lwsock32 -lws2_32)
2015-03-26 19:24:46 +00:00
remove_definitions(-DUNICODE)
2015-08-21 17:02:27 +00:00
add_definitions(-mwindows -D_WIN32)
2015-04-18 12:22:11 +00:00
endif()
2015-03-26 19:24:46 +00:00
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)
2015-09-02 23:52:34 +00:00
add_subdirectory(subsurface-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-11-05 23:06:10 +00:00
if (NOT SUBSURFACE_MOBILE)
add_subdirectory(desktop-widgets)
endif()
2014-04-14 17:21:01 +00:00
2015-05-02 02:17:22 +00:00
if(FBSUPPORT)
add_definitions(-DFBSUPPORT)
2015-12-01 19:46:59 +00:00
set(FACEBOOK_INTEGRATION facebook_integration)
2015-05-02 02:17:22 +00:00
endif()
2015-03-26 20:50:28 +00:00
2015-04-16 14:22:09 +00:00
# add pthread to the end of the library list on Linux
# this is only needed on Ubuntu (why do these idiots break everything?)
# but shouldn't hurt on other Linux versions
2015-07-08 22:42:12 +00:00
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ANDROID)
2015-04-18 12:22:11 +00:00
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lpthread)
2015-04-16 14:22:09 +00:00
endif()
2015-03-26 20:50:28 +00:00
# create the executables
2015-05-27 12:33:23 +00:00
if(SUBSURFACE_MOBILE)
2015-11-30 23:06:18 +00:00
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(SUBSURFACE_TARGET Subsurface-mobile)
else()
set(SUBSURFACE_TARGET subsurface-mobile)
endif()
2015-09-03 17:49:59 +00:00
set(MOBILE_SRC
qt-mobile/qmlmanager.cpp
qt-mobile/qmlprofile.cpp
qt-models/divelistmodel.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
)
2015-11-06 23:39:06 +00:00
qt5_add_resources(MOBILE_RESOURCES qt-mobile/qml/mobile-resources.qrc)
2015-07-09 22:02:35 +00:00
if(ANDROID)
2015-09-03 17:49:59 +00:00
add_library(subsurface-mobile SHARED ${MOBILE_SRC} ${SUBSURFACE_PKG} ${SUBSURFACE_RESOURCES} ${MOBILE_RESOURCES})
2015-07-09 22:02:35 +00:00
else()
2015-11-30 23:06:18 +00:00
add_executable(${SUBSURFACE_TARGET} ${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
${SUBSURFACE_LINK_LIBRARIES})
else()
# the main app.
set(SUBSURFACE_APP
subsurface-desktop-main.cpp
subsurface-desktop-helper.cpp
)
source_group("Subsurface App" FILES ${SUBSURFACE_APP})
if(ANDROID)
# Produce a shared-library instead of a program.
# Something that androiddeployqt can work with.
# this is the desktop version, running on android.
add_library(${SUBSURFACE_TARGET} SHARED ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES})
else()
add_executable(${SUBSURFACE_TARGET} MACOSX_BUNDLE WIN32 ${SUBSURFACE_PKG} ${SUBSURFACE_APP} ${SUBSURFACE_RESOURCES})
endif()
2015-11-10 19:51:40 +00:00
if(SMARTTRAK_IMPORT)
set(SMTK_IMPORT_TARGET smtk2ssrf)
add_executable(smtk2ssrf smtk-import/smtk_standalone.cpp ${SUBSURFACE_RESOURCES})
target_link_libraries(smtk2ssrf smtk_import)
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)
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-06-20 04:33:29 +00:00
# install a few things so that one can run Subsurface from the build
# directory
2015-06-20 13:06:32 +00:00
if(NOT insource)
add_custom_target(themeLink ALL
COMMAND
rm -f ${CMAKE_BINARY_DIR}/theme &&
ln -s ${CMAKE_SOURCE_DIR}/theme ${CMAKE_BINARY_DIR}/theme
)
if(NOT NO_PRINTING)
add_custom_target(printing_templatesLink ALL
COMMAND
rm -f ${CMAKE_BINARY_DIR}/printing_templates &&
ln -s ${CMAKE_SOURCE_DIR}/printing_templates ${CMAKE_BINARY_DIR}/printing_templates
)
endif()
if(NOT NO_DOCS)
add_custom_target(
documentationLink ALL
COMMAND
mkdir -p ${CMAKE_BINARY_DIR}/Documentation/ &&
2015-06-20 13:46:49 +00:00
rm -rf ${CMAKE_BINARY_DIR}/Documentation/images &&
2015-06-20 13:06:32 +00:00
ln -s ${CMAKE_SOURCE_DIR}/Documentation/images ${CMAKE_BINARY_DIR}/Documentation/images
)
endif()
2015-06-27 22:28:27 +00:00
else()
if(NOT NO_DOCS)
add_custom_target(
documentationLink ALL
)
endif()
2015-06-20 04:33:29 +00:00
endif()
2015-04-18 12:22:11 +00:00
if(NOT NO_DOCS)
2015-04-24 18:02:45 +00:00
add_custom_target(
documentation ALL
2015-06-27 22:28:27 +00:00
COMMAND
2015-07-16 20:31:32 +00:00
${CMAKE_MAKE_PROGRAM} -C ${CMAKE_SOURCE_DIR}/Documentation OUT=${CMAKE_BINARY_DIR}/Documentation/ doc
2015-06-27 22:28:27 +00:00
DEPENDS documentationLink
2015-04-24 18:02:45 +00:00
)
2015-04-18 12:22:11 +00:00
endif()
2015-03-30 21:43:15 +00:00
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
)
2015-03-31 20:39:09 +00:00
set(QTTRANSLATIONS_BASE
qt_da.qm
qt_de.qm
qt_es.qm
qt_fr.qm
qt_he.qm
qt_hu.qm
qt_pl.qm
qt_pt.qm
qt_ru.qm
qt_sk.qm
qt_sv.qm
qt_zh_TW.qm
)
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 "")
set(QTTRANSLATIONS ${QTTRANSLATIONS} ${QT_TRANSLATION_DIR}/${QTTRANSLATION})
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
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
2015-11-30 23:06:18 +00:00
if(SUBSURFACE_MOBILE)
set(APP_BUNDLE_DIR Subsurface-mobile.app)
set(MACDEPLOY_ARGS "-qmldir=${APP_BUNDLE_DIR}/Contents/Frameworks/qml")
else()
set(APP_BUNDLE_DIR Subsurface.app)
endif()
set(RESOURCEDIR ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Resources)
set(PLUGINDIR ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/PlugIns)
2015-04-04 20:13:46 +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})
2015-04-21 15:15:40 +00:00
install(DIRECTORY printing_templates DESTINATION ${RESOURCEDIR})
2015-04-04 20:13:46 +00:00
install(FILES ${TRANSLATIONS} DESTINATION ${RESOURCEDIR}/translations)
install(FILES ${QTTRANSLATIONS} DESTINATION ${RESOURCEDIR}/translations)
install(FILES ${CMAKE_SOURCE_DIR}/gpl-2.0.txt DESTINATION ${RESOURCEDIR})
2015-08-27 20:44:33 +00:00
# this is a HACK
install(DIRECTORY ${Grantlee5_DIR}/../../grantlee DESTINATION ${PLUGINDIR})
2015-04-10 20:15:19 +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-11-30 23:06:18 +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
2015-12-06 21:44:32 +00:00
if(SUBSURFACE_MOBILE)
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()
2015-12-09 23:23:14 +00:00
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)")
install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework/Versions/5/*_debug)")
install(CODE "execute_process(COMMAND rm -rf ${CMAKE_BINARY_DIR}/${APP_BUNDLE_DIR}/Contents/Frameworks/QtXml.framework//*_debug)")
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-08-27 20:44:33 +00:00
install(CODE "message(STATUS \"two ERRORS here about libmysqlclient and libpq not found are harmless\")")
2015-04-18 12:22:11 +00:00
endif()
2015-03-30 19:50:52 +00:00
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
2015-04-18 12:22:09 +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
2015-03-31 21:03:02 +00:00
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})
2015-04-21 15:15:40 +00:00
install(DIRECTORY printing_templates DESTINATION ${WINDOWSSTAGING})
2015-03-31 21:03:02 +00:00
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})
2015-04-05 13:53:17 +00:00
install(TARGETS ${SUBSURFACE_TARGET} DESTINATION ${WINDOWSSTAGING})
2015-03-31 21:03:02 +00:00
install(FILES ${CMAKE_BINARY_DIR}/qt.conf DESTINATION ${WINDOWSSTAGING})
2015-06-20 05:24:18 +00:00
install(DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/grantlee DESTINATION ${WINDOWSSTAGING})
2015-04-01 20:36:38 +00:00
if(NOT DEFINED MAKENSIS)
set(MAKENSIS makensis)
endif()
2015-04-03 17:05:05 +00:00
# next figure out the DLLs we need to include in the installer
# since this needs to run at install time we create a new cmake
# script that then gets executed at install time with install(CODE...)
2015-04-18 12:22:11 +00:00
file(WRITE ${CMAKE_BINARY_DIR}/dlllist.cmake "
message(STATUS \"processing dlllist.cmake\")
2015-04-03 17:05:05 +00:00
# figure out which command to use for objdump
2015-04-18 12:22:11 +00:00
execute_process(
2015-04-03 17:05:05 +00:00
COMMAND ${CMAKE_C_COMPILER} -dumpmachine
OUTPUT_VARIABLE OBJDUMP
OUTPUT_STRIP_TRAILING_WHITESPACE
2015-04-18 12:22:14 +00:00
)
2015-04-03 17:05:05 +00:00
# figure out where we should search for libraries
2015-04-18 12:22:11 +00:00
execute_process(
2015-04-03 17:05:05 +00:00
COMMAND ${CMAKE_C_COMPILER} -print-search-dirs
COMMAND sed -nE \"/^libraries: =/{s///;s,/lib/?\\\(:|\\\$\\\$\\\),/bin\\\\1,g;p;q;}\"
OUTPUT_VARIABLE ADDPATH
OUTPUT_STRIP_TRAILING_WHITESPACE
2015-04-18 12:22:14 +00:00
)
2015-04-03 17:05:05 +00:00
# since cmake doesn't appear to give us a variable with
# all libraries we link against, grab the link.txt script
# instead and drop the command name from it (before the
# first space) -- this will fail if the full path for the
# linker used contains a space...
2015-04-18 12:22:11 +00:00
execute_process(
2015-04-03 17:05:05 +00:00
COMMAND tail -1 CMakeFiles/subsurface.dir/link.txt
2015-04-28 20:40:18 +00:00
COMMAND cut -d\\ -f 2-
2015-04-03 17:05:05 +00:00
OUTPUT_VARIABLE LINKER_LINE
OUTPUT_STRIP_TRAILING_WHITESPACE
2015-04-18 12:22:14 +00:00
)
2015-04-03 17:05:05 +00:00
# finally run our win-ldd.pl script against that to
# collect all the required dlls
2015-04-18 12:22:11 +00:00
execute_process(
2015-04-05 13:53:17 +00:00
COMMAND sh -c \"OBJDUMP=\${OBJDUMP}-objdump PATH=$ENV{PATH}:\${ADDPATH} perl ${CMAKE_SOURCE_DIR}/scripts/win-ldd.pl ${SUBSURFACE_TARGET}.exe \${LINKER_LINE}\"
2015-04-03 17:05:05 +00:00
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
OUTPUT_VARIABLE DLLS
OUTPUT_STRIP_TRAILING_WHITESPACE
2015-04-18 12:22:14 +00:00
)
2015-04-03 17:05:05 +00:00
# replace newlines with semicolons so this is a cmake list
string(REPLACE \"\\n\" \";\" DLLLIST \${DLLS})
# executing 'install' as a command seems hacky, but you
# can't use the install() cmake function in a script
foreach(DLL \${DLLLIST})
2015-04-18 12:22:11 +00:00
execute_process(COMMAND install \${DLL} \${STAGING})
2015-04-03 17:05:05 +00:00
endforeach()
")
# 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
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -DSTAGING=${WINDOWSSTAGING} -P ${CMAKE_BINARY_DIR}/dlllist.cmake)")
# 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
2015-04-18 12:22:14 +00:00
add_custom_target(
fake_install
2015-04-01 20:36:38 +00:00
COMMAND "${CMAKE_COMMAND}" --build . --target install
2015-04-05 13:53:17 +00:00
DEPENDS ${SUBSURFACE_TARGET}
2015-04-18 12:22:14 +00:00
)
2015-04-03 17:05:05 +00:00
2015-04-18 12:22:14 +00:00
add_custom_target(
installer
2015-04-01 20:36:38 +00:00
COMMAND ${MAKENSIS} ${WINDOWSSTAGING}/subsurface.nsi
DEPENDS fake_install
2015-04-18 12:22:14 +00:00
)
2015-04-18 12:22:11 +00:00
endif()
2015-03-30 19:50:52 +00:00
2015-07-08 22:42:12 +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-07-09 22:02:35 +00:00
if(SUBSURFACE_MOBILE)
2015-07-09 23:37:43 +00:00
set(ANDROID_PACKAGE_SOURCE_DIR, ${CMAKE_BINARY_DIR}/android-mobile)
2015-07-09 22:02:35 +00:00
add_qt_android_apk(subsurface-mobile.apk subsurface-mobile
2015-07-10 18:22:39 +00:00
PACKAGE_SOURCES ${CMAKE_CURRENT_LIST_DIR}/android-mobile
2015-07-08 22:42:12 +00:00
)
2015-07-09 22:02:35 +00:00
else()
2015-07-09 23:37:43 +00:00
set(ANDROID_PACKAGE_SOURCE_DIR, ${CMAKE_BINARY_DIR}/android)
2015-07-09 22:02:35 +00:00
add_qt_android_apk(subsurface.apk ${SUBSURFACE_TARGET}
PACKAGE_SOURCES ${CMAKE_CURRENT_LIST_DIR}/android
)
endif()
2015-04-18 12:22:11 +00:00
endif()
2015-03-30 19:50:52 +00:00
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
install(DIRECTORY marbledata/maps DESTINATION share/subsurface/data)
install(DIRECTORY marbledata/bitmaps DESTINATION share/subsurface/data)
2015-10-29 11:21:18 +00:00
install(FILES subsurface.debug DESTINATION bin)
2015-03-30 19:50:52 +00:00
install(FILES subsurface.desktop DESTINATION share/applications)
2015-09-03 16:35:11 +00:00
install(FILES icons/subsurface-icon.svg DESTINATION share/icons/hicolor/scalable/apps)
2015-03-30 19:50:52 +00:00
install(DIRECTORY Documentation/images DESTINATION share/subsurface/Documentation)
install(FILES ${DOCFILES} DESTINATION share/subsurface/Documentation)
install(DIRECTORY theme DESTINATION share/subsurface)
2015-04-21 15:15:40 +00:00
install(DIRECTORY printing_templates DESTINATION share/subsurface)
2015-03-30 19:50:52 +00:00
install(FILES ${TRANSLATIONS} DESTINATION share/subsurface/translations)
2015-05-27 12:33:23 +00:00
if(SUBSURFACE_MOBILE)
install(TARGETS subsurface-mobile DESTINATION bin)
else()
install(TARGETS ${SUBSURFACE_TARGET} DESTINATION bin)
2015-11-10 19:51:40 +00:00
if (SMARTTRAK_IMPORT)
install(TARGETS ${SMTK_IMPORT_TARGET} DESTINATION bin)
endif()
2015-05-27 12:33:23 +00:00
endif()
2015-04-18 12:22:11 +00:00
if(DEFINED LIBMARBLEDEVEL)
2015-04-06 04:10:40 +00:00
install(
CODE "file(GLOB SSRFMARBLE_SHLIBS \"${LIBMARBLEDEVEL}/lib/libssrfmarblewidget.so*\")"
CODE "file(INSTALL \${SSRFMARBLE_SHLIBS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)"
2015-04-18 12:22:14 +00:00
)
2015-04-18 12:22:11 +00:00
endif()
endif()
2015-09-03 20:10:50 +00:00
2015-09-28 11:42:35 +00:00
# get_cmake_property(_variableNames VARIABLES)
# foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
# endforeach()
2015-09-03 20:10:50 +00:00
if (MAKE_TESTS)
add_subdirectory(tests)
endif()