syncthingtray/connector/CMakeLists.txt

134 lines
5.2 KiB
CMake
Raw Normal View History

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")
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)
# add project files
set(HEADER_FILES
syncthingdir.h
syncthingdev.h
syncthingconnection.h
syncthingconnectionsettings.h
syncthingnotifier.h
syncthingconfig.h
syncthingprocess.h
syncthingservice.h
2019-02-06 17:36:14 +01:00
utils.h)
set(SRC_FILES
syncthingdir.cpp
syncthingdev.cpp
syncthingconnection.cpp
syncthingconnection_requests.cpp
syncthingconnectionsettings.cpp
syncthingnotifier.cpp
syncthingconfig.cpp
syncthingprocess.cpp
syncthingservice.cpp
2019-02-06 17:36:14 +01:00
utils.cpp)
2019-02-06 17:36:14 +01:00
set(TEST_HEADER_FILES)
set(TEST_SRC_FILES tests/connectiontests.cpp tests/misctests.cpp)
2016-09-21 21:05:31 +02:00
2019-02-06 17:36:14 +01:00
set(TS_FILES translations/${META_PROJECT_NAME}_de_DE.ts translations/${META_PROJECT_NAME}_en_US.ts)
2016-10-05 23:01:53 +02:00
# find c++utilities
find_package(c++utilities 4.17.0 REQUIRED)
use_cpp_utilities()
set(META_PUBLIC_SHARED_LIB_DEPENDS c++utilities)
set(META_PUBLIC_STATIC_LIB_DEPENDS c++utilities_static)
2016-10-03 00:41:38 +02:00
# find qtutilities (only headers and CMake modules used)
find_package(qtutilities 5.0.0 REQUIRED)
2016-10-03 00:41:38 +02:00
list(APPEND CMAKE_MODULE_PATH ${QT_UTILITIES_MODULE_DIRS})
list(APPEND PRIVATE_SHARED_INCLUDE_DIRS ${QT_UTILITIES_INCLUDE_DIRS})
list(APPEND PRIVATE_STATIC_INCLUDE_DIRS ${QT_UTILITIES_INCLUDE_DIRS})
# link also explicitely against the following Qt 5 modules
list(APPEND ADDITIONAL_QT_MODULES Network)
set(META_PUBLIC_QT_MODULES Core ${ADDITIONAL_QT_MODULES})
# configure support for controlling Syncthing via systemd service
2019-02-06 17:36:14 +01:00
if (UNIX AND NOT APPLE)
set(ENABLE_SYSTEMD_SUPPORT_BY_DEFAULT ON)
2019-02-06 17:36:14 +01:00
else ()
set(ENABLE_SYSTEMD_SUPPORT_BY_DEFAULT OFF)
2019-02-06 17:36:14 +01:00
endif ()
option(SYSTEMD_SUPPORT "enables support for controlling Syncthing systemd service" ${ENABLE_SYSTEMD_SUPPORT_BY_DEFAULT})
2019-02-06 17:36:14 +01:00
if (SYSTEMD_SUPPORT)
list(APPEND DBUS_FILES
2019-02-06 17:36:14 +01:00
org.freedesktop.DBus.Properties.xml
org.freedesktop.login1.LoginManager.xml
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)
2018-10-12 00:20:15 +02:00
list(APPEND META_PUBLIC_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME_UPPER}_SUPPORT_SYSTEMD)
message(STATUS "systemd support enabled")
2019-02-06 17:36:14 +01:00
else ()
message(STATUS "systemd support disabled")
2019-02-06 17:36:14 +01:00
endif ()
# configure whether the connection should be mocked for test purposes
2019-02-06 17:36:14 +01:00
option(SYNCTHING_CONNECTION_MOCKED
"enables mocking the SyncthingConnection class so it will provide only some fixed test data" OFF)
if (SYNCTHING_CONNECTION_MOCKED)
list(APPEND SRC_FILES syncthingconnectionmockhelpers.h syncthingconnectionmockhelpers.cpp)
set_property(SOURCE syncthingconnection.cpp
syncthingconnection_requests.cpp
syncthingconnectionmockhelpers.h
syncthingconnectionmockhelpers.cpp
APPEND
PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME_UPPER}_CONNECTION_MOCKED)
message(WARNING "SyncthingConnection class will be mocked")
2019-02-06 17:36:14 +01:00
endif ()
2018-04-20 23:00:56 +02:00
# configure whether the service should be mocked for test purposes
option(SYNCTHING_SERVICE_MOCKED "enables mocking the SyncthingService class so it will provide some fake status" OFF)
2019-02-06 17:36:14 +01:00
if (SYNCTHING_SERVICE_MOCKED)
set_property(SOURCE syncthingservice.cpp
APPEND
PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME_UPPER}_SERVICE_MOCKED)
2018-04-20 23:00:56 +02:00
message(WARNING "SyncthingService class will be mocked")
2019-02-06 17:36:14 +01:00
endif ()
2018-04-20 23:00:56 +02:00
# configure whether events should be logged
option(SYNCTHING_CONNECTION_LOG_SYNCTHING_EVENTS "enables logging event data to stdout (enable only for debugging!)" OFF)
2019-02-06 17:36:14 +01:00
if (SYNCTHING_CONNECTION_LOG_SYNCTHING_EVENTS)
set_property(SOURCE syncthingconnection_requests.cpp
APPEND
PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME_UPPER}_LOG_SYNCTHING_EVENTS)
2018-10-12 00:20:15 +02:00
message(WARNING "SyncthingConnection class will log event data to stdout")
2019-02-06 17:36:14 +01:00
endif ()
2018-10-12 00:20:15 +02:00
# configure whether POSTs should be logged
2019-02-06 17:36:14 +01:00
option(SYNCTHING_CONNECTION_LOG_API_CALLS
"enables logging API calls done by the SyncthingConnector (enable only for debugging!)" OFF)
if (SYNCTHING_CONNECTION_LOG_API_CALLS)
set_property(SOURCE syncthingconnection_requests.cpp
APPEND
PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME_UPPER}_LOG_API_CALLS)
message(WARNING "SyncthingConnection class will log API calls data to stdout")
2019-02-06 17:36:14 +01:00
endif ()
# include modules to apply configuration
include(BasicConfig)
include(QtConfig)
include(WindowsResources)
include(LibraryTarget)
2019-02-06 17:36:14 +01: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)
2019-02-06 17:36:14 +01:00
else ()
list(APPEND TEST_LIBRARIES syncthingtesthelper_static)
2019-02-06 17:36:14 +01:00
endif ()
2016-09-21 21:05:31 +02:00
include(TestTarget)
include(Doxygen)
include(ConfigHeader)