2016-09-30 23:55:25 +02:00
|
|
|
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
|
|
|
|
|
|
|
# metadata
|
|
|
|
set(META_PROJECT_NAME syncthingconnector)
|
|
|
|
set(META_PROJECT_TYPE library)
|
2016-10-02 21:59:28 +02:00
|
|
|
set(META_APP_NAME "Connection backend of Syncthing Tray")
|
2016-09-30 23:55:25 +02:00
|
|
|
set(META_APP_DESCRIPTION "Connection backend of Syncthing Tray")
|
|
|
|
set(META_PROJECT_VARNAME_UPPER LIB_SYNCTHING_CONNECTOR)
|
2016-11-08 20:00:20 +01:00
|
|
|
set(META_PUBLIC_QT_MODULES Core Network)
|
2016-09-30 23:55:25 +02:00
|
|
|
|
|
|
|
# add project files
|
|
|
|
set(HEADER_FILES
|
2016-10-04 23:55:20 +02:00
|
|
|
syncthingdir.h
|
|
|
|
syncthingdev.h
|
2016-09-30 23:55:25 +02:00
|
|
|
syncthingconnection.h
|
|
|
|
syncthingconnectionsettings.h
|
2017-11-26 03:17:30 +01:00
|
|
|
syncthingnotifier.h
|
2016-09-30 23:55:25 +02:00
|
|
|
syncthingconfig.h
|
|
|
|
syncthingprocess.h
|
2017-01-14 21:36:37 +01:00
|
|
|
syncthingservice.h
|
2016-09-30 23:55:25 +02:00
|
|
|
utils.h
|
|
|
|
)
|
|
|
|
set(SRC_FILES
|
2016-10-04 23:55:20 +02:00
|
|
|
syncthingdir.cpp
|
|
|
|
syncthingdev.cpp
|
2016-09-30 23:55:25 +02:00
|
|
|
syncthingconnection.cpp
|
|
|
|
syncthingconnectionsettings.cpp
|
2017-11-26 03:17:30 +01:00
|
|
|
syncthingnotifier.cpp
|
2016-09-30 23:55:25 +02:00
|
|
|
syncthingconfig.cpp
|
|
|
|
syncthingprocess.cpp
|
2017-01-14 21:36:37 +01:00
|
|
|
syncthingservice.cpp
|
2016-09-30 23:55:25 +02:00
|
|
|
utils.cpp
|
|
|
|
)
|
|
|
|
|
2016-09-21 21:05:31 +02:00
|
|
|
set(TEST_HEADER_FILES
|
|
|
|
)
|
|
|
|
set(TEST_SRC_FILES
|
|
|
|
tests/cppunit.cpp
|
|
|
|
tests/connectiontests.cpp
|
2017-03-09 23:06:03 +01:00
|
|
|
tests/misctests.cpp
|
2016-09-21 21:05:31 +02:00
|
|
|
)
|
|
|
|
|
2016-10-05 23:01:53 +02:00
|
|
|
set(TS_FILES
|
|
|
|
translations/${META_PROJECT_NAME}_de_DE.ts
|
|
|
|
translations/${META_PROJECT_NAME}_en_US.ts
|
|
|
|
)
|
|
|
|
|
2016-09-30 23:55:25 +02:00
|
|
|
# find c++utilities
|
2017-07-11 22:40:04 +02:00
|
|
|
find_package(c++utilities 4.9.0 REQUIRED)
|
2016-09-30 23:55:25 +02:00
|
|
|
use_cpp_utilities()
|
2017-01-13 10:25:50 +01:00
|
|
|
set(META_PUBLIC_SHARED_LIB_DEPENDS c++utilities)
|
|
|
|
set(META_PUBLIC_STATIC_LIB_DEPENDS c++utilities_static)
|
2016-09-30 23:55:25 +02:00
|
|
|
|
2016-10-03 00:41:38 +02:00
|
|
|
# find qtutilities (only headers and CMake modules used)
|
2016-09-30 23:55:25 +02:00
|
|
|
find_package(qtutilities 5.0.0 REQUIRED)
|
2016-10-03 00:41:38 +02:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${QT_UTILITIES_MODULE_DIRS})
|
2017-07-11 22:40:04 +02:00
|
|
|
list(APPEND PRIVATE_SHARED_INCLUDE_DIRS ${QT_UTILITIES_INCLUDE_DIRS})
|
|
|
|
list(APPEND PRIVATE_STATIC_INCLUDE_DIRS ${QT_UTILITIES_INCLUDE_DIRS})
|
2017-04-01 16:56:36 +02:00
|
|
|
|
2016-09-30 23:55:25 +02:00
|
|
|
# link also explicitely against the following Qt 5 modules
|
|
|
|
list(APPEND ADDITIONAL_QT_MODULES Network)
|
2017-08-06 00:37:49 +02:00
|
|
|
set(META_PUBLIC_QT_MODULES Core ${ADDITIONAL_QT_MODULES})
|
2016-09-30 23:55:25 +02:00
|
|
|
|
2017-01-03 00:00:05 +01:00
|
|
|
# configure support for controlling Syncthing via systemd service
|
2017-08-06 00:38:30 +02:00
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
set(ENABLE_SYSTEMD_SUPPORT_BY_DEFAULT ON)
|
|
|
|
else()
|
|
|
|
set(ENABLE_SYSTEMD_SUPPORT_BY_DEFAULT OFF)
|
|
|
|
endif()
|
|
|
|
option(SYSTEMD_SUPPORT "enables support for controlling Syncthing systemd service" ${ENABLE_SYSTEMD_SUPPORT_BY_DEFAULT})
|
2017-01-03 00:34:48 +01:00
|
|
|
if(SYSTEMD_SUPPORT)
|
2016-12-18 16:50:35 +01:00
|
|
|
list(APPEND DBUS_FILES
|
|
|
|
org.freedesktop.DBus.Properties.xml
|
2017-01-14 21:37:42 +01:00
|
|
|
org.freedesktop.login1.LoginManager.xml
|
2016-12-18 16:50:35 +01:00
|
|
|
org.freedesktop.systemd1.Manager.xml
|
|
|
|
org.freedesktop.systemd1.Service.xml
|
|
|
|
org.freedesktop.systemd1.Unit.xml
|
|
|
|
)
|
|
|
|
set_source_files_properties(
|
|
|
|
org.freedesktop.systemd1.Manager.xml
|
|
|
|
PROPERTIES INCLUDE syncthingservice.h
|
|
|
|
)
|
|
|
|
list(APPEND META_PUBLIC_COMPILE_DEFINITIONS LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD)
|
|
|
|
message(STATUS "systemd support enabled")
|
|
|
|
else()
|
|
|
|
message(STATUS "systemd support disabled")
|
|
|
|
endif()
|
|
|
|
|
2017-09-05 00:22:52 +02:00
|
|
|
# configure whether the connection should be mocked for test purposes
|
|
|
|
option(SYNCTHING_CONNECTION_MOCKED "enables mocking the SyncthingConnection class so it will provide only some fixed test data" OFF)
|
|
|
|
if(SYNCTHING_CONNECTION_MOCKED)
|
2017-09-05 00:35:54 +02:00
|
|
|
list(APPEND SRC_FILES
|
|
|
|
syncthingconnectionmockhelpers.h
|
|
|
|
syncthingconnectionmockhelpers.cpp
|
|
|
|
)
|
2017-09-05 00:22:52 +02:00
|
|
|
set_source_files_properties(
|
|
|
|
syncthingconnection.cpp
|
|
|
|
syncthingconnectionmockhelpers.h
|
|
|
|
syncthingconnectionmockhelpers.cpp
|
|
|
|
PROPERTIES COMPILE_DEFINITIONS LIB_SYNCTHING_CONNECTOR_CONNECTION_MOCKED
|
|
|
|
)
|
|
|
|
message(WARNING "SyncthingConnection class will be mocked")
|
|
|
|
endif()
|
|
|
|
|
2018-03-31 19:48:27 +02:00
|
|
|
# configure whether events should be logged
|
|
|
|
option(SYNCTHING_CONNECTION_LOG_SYNCTHING_EVENTS "enables logging event data" OFF)
|
|
|
|
if(SYNCTHING_CONNECTION_LOG_SYNCTHING_EVENTS)
|
|
|
|
set_source_files_properties(
|
|
|
|
syncthingconnection.cpp
|
|
|
|
PROPERTIES COMPILE_DEFINITIONS LIB_SYNCTHING_CONNECTOR_LOG_SYNCTHING_EVENTS
|
|
|
|
)
|
|
|
|
message(WARNING "SyncthingConnection class will be mocked")
|
|
|
|
endif()
|
|
|
|
|
2016-09-30 23:55:25 +02:00
|
|
|
# include modules to apply configuration
|
|
|
|
include(BasicConfig)
|
|
|
|
include(QtConfig)
|
|
|
|
include(WindowsResources)
|
|
|
|
include(LibraryTarget)
|
2017-07-11 22:40:04 +02:00
|
|
|
|
|
|
|
# link tests against test helper (can't use find_package because testhelper target is not
|
|
|
|
# present at this point)
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
list(APPEND TEST_LIBRARIES syncthingtesthelper)
|
|
|
|
else()
|
|
|
|
list(APPEND TEST_LIBRARIES syncthingtesthelper_static)
|
|
|
|
endif()
|
2016-09-21 21:05:31 +02:00
|
|
|
include(TestTarget)
|
2017-07-11 22:40:04 +02:00
|
|
|
|
2016-09-30 23:55:25 +02:00
|
|
|
include(Doxygen)
|
|
|
|
include(ConfigHeader)
|