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
|
2020-03-01 22:04:30 +01:00
|
|
|
syncthingcompletion.h
|
2016-10-04 23:55:20 +02:00
|
|
|
syncthingdir.h
|
|
|
|
syncthingdev.h
|
2016-09-30 23:55:25 +02:00
|
|
|
syncthingconnection.h
|
2020-03-17 18:55:50 +01:00
|
|
|
syncthingconnectionstatus.h
|
2016-09-30 23:55:25 +02:00
|
|
|
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
|
2020-03-02 15:38:38 +01:00
|
|
|
qstringhash.h
|
2019-02-06 17:36:14 +01:00
|
|
|
utils.h)
|
2016-09-30 23:55:25 +02:00
|
|
|
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
|
2018-10-28 15:37:25 +01:00
|
|
|
syncthingconnection_requests.cpp
|
2016-09-30 23:55:25 +02:00
|
|
|
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
|
2019-02-06 17:36:14 +01:00
|
|
|
utils.cpp)
|
2016-09-30 23:55:25 +02:00
|
|
|
|
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
|
|
|
|
2021-10-07 18:28:13 +02:00
|
|
|
set(TS_FILES translations/${META_PROJECT_NAME}_zh_CN.ts translations/${META_PROJECT_NAME}_cs_CZ.ts
|
|
|
|
translations/${META_PROJECT_NAME}_de_DE.ts translations/${META_PROJECT_NAME}_en_US.ts)
|
2016-10-05 23:01:53 +02:00
|
|
|
|
2016-09-30 23:55:25 +02:00
|
|
|
# find c++utilities
|
2021-10-02 11:58:02 +02:00
|
|
|
find_package(${PACKAGE_NAMESPACE_PREFIX}c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.10.0 REQUIRED)
|
2019-03-13 19:12:23 +01:00
|
|
|
use_cpp_utilities(VISIBILITY PUBLIC)
|
2016-09-30 23:55:25 +02:00
|
|
|
|
2016-10-03 00:41:38 +02:00
|
|
|
# find qtutilities (only headers and CMake modules used)
|
2021-10-02 11:58:02 +02:00
|
|
|
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.3.0 REQUIRED)
|
2021-01-01 18:50:46 +01:00
|
|
|
use_qt_utilities(ONLY_HEADERS VISIBILITY PUBLIC)
|
2017-04-01 16:56:36 +02:00
|
|
|
|
2021-06-09 20:59:09 +02:00
|
|
|
# find boost libraries
|
|
|
|
option(USE_BOOST_PROCESS "enables Boost.Process for improved behavior of the launcher" ON)
|
|
|
|
if (USE_BOOST_PROCESS)
|
|
|
|
option(BOOST_STATIC_LINKAGE "${STATIC_LINKAGE}" "link statically against Boost (instead of dynamically)")
|
|
|
|
set(Boost_USE_MULTITHREADED ON)
|
|
|
|
if (BOOST_STATIC_LINKAGE)
|
|
|
|
set(Boost_USE_STATIC_LIBS ON)
|
|
|
|
endif ()
|
2021-06-27 18:54:43 +02:00
|
|
|
# add Boost::boost target which represents include directory for header-only deps and add Boost::filesystem as it is
|
|
|
|
# needed by Boost.Process
|
2023-01-28 20:19:16 +01:00
|
|
|
set(BOOST_ARGS 1.75 REQUIRED) # 1.66 does not invoke on_exit handler correctly, 1.75 was the next version I tested and it
|
|
|
|
# worked
|
2021-06-17 20:32:25 +02:00
|
|
|
list(APPEND BOOST_ARGS COMPONENTS filesystem)
|
2021-06-09 20:59:09 +02:00
|
|
|
use_package(TARGET_NAME Boost::boost PACKAGE_NAME Boost PACKAGE_ARGS "${BOOST_ARGS}")
|
2021-06-17 20:32:25 +02:00
|
|
|
use_package(TARGET_NAME Boost::filesystem PACKAGE_NAME Boost PACKAGE_ARGS "${BOOST_ARGS}")
|
2021-06-09 20:59:09 +02:00
|
|
|
list(APPEND META_PUBLIC_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME_UPPER}_BOOST_PROCESS)
|
2021-06-27 18:54:43 +02:00
|
|
|
if (WIN32)
|
|
|
|
list(APPEND PRIVATE_LIBRARIES ws2_32) # needed by Boost.Asio
|
|
|
|
endif ()
|
2021-06-09 20:59:09 +02:00
|
|
|
if (MINGW)
|
|
|
|
# workaround https://github.com/boostorg/process/issues/96
|
|
|
|
set_property(
|
|
|
|
SOURCE syncthingprocess.cpp
|
|
|
|
APPEND
|
|
|
|
PROPERTY COMPILE_DEFINITIONS BOOST_USE_WINDOWS_H WIN32_LEAN_AND_MEAN)
|
|
|
|
endif ()
|
2021-06-21 17:44:43 +02:00
|
|
|
# add threading library as it is needed by Boost.Process
|
|
|
|
use_package(TARGET_NAME Threads::Threads PACKAGE_NAME Threads PACKAGE_ARGS REQUIRED)
|
2021-06-09 20:59:09 +02:00
|
|
|
endif ()
|
|
|
|
|
2021-07-03 19:29:49 +02:00
|
|
|
# link also explicitly against the following Qt modules
|
2016-09-30 23:55:25 +02:00
|
|
|
list(APPEND ADDITIONAL_QT_MODULES Network)
|
|
|
|
|
2017-01-03 00:00:05 +01:00
|
|
|
# configure support for controlling Syncthing via systemd service
|
2019-02-06 17:36:14 +01:00
|
|
|
if (UNIX AND NOT APPLE)
|
2017-08-06 00:38:30 +02:00
|
|
|
set(ENABLE_SYSTEMD_SUPPORT_BY_DEFAULT ON)
|
2019-02-06 17:36:14 +01:00
|
|
|
else ()
|
2017-08-06 00:38:30 +02:00
|
|
|
set(ENABLE_SYSTEMD_SUPPORT_BY_DEFAULT OFF)
|
2019-02-06 17:36:14 +01:00
|
|
|
endif ()
|
2017-08-06 00:38:30 +02:00
|
|
|
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)
|
2020-02-02 19:50:35 +01:00
|
|
|
list(
|
|
|
|
APPEND
|
|
|
|
DBUS_FILES
|
|
|
|
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)
|
2019-11-30 18:24:19 +01:00
|
|
|
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)
|
2016-12-18 16:50:35 +01:00
|
|
|
message(STATUS "systemd support enabled")
|
2019-02-06 17:36:14 +01:00
|
|
|
else ()
|
2016-12-18 16:50:35 +01:00
|
|
|
message(STATUS "systemd support disabled")
|
2019-02-06 17:36:14 +01:00
|
|
|
endif ()
|
2016-12-18 16:50:35 +01:00
|
|
|
|
2020-03-05 19:04:55 +01:00
|
|
|
# configure whether the SyncthingConnection class 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)
|
2019-11-30 18:24:19 +01:00
|
|
|
set_property(
|
|
|
|
SOURCE syncthingconnection.cpp syncthingconnection_requests.cpp syncthingconnectionmockhelpers.h
|
|
|
|
syncthingconnectionmockhelpers.cpp
|
|
|
|
APPEND
|
|
|
|
PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME_UPPER}_CONNECTION_MOCKED)
|
2017-09-05 00:22:52 +02:00
|
|
|
message(WARNING "SyncthingConnection class will be mocked")
|
2019-02-06 17:36:14 +01:00
|
|
|
endif ()
|
2017-09-05 00:22:52 +02:00
|
|
|
|
2020-03-05 19:04:55 +01:00
|
|
|
# configure whether the SyncthingService class should be mocked for test purposes
|
2018-04-20 23:00:56 +02:00
|
|
|
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)
|
2020-08-11 23:15:41 +02:00
|
|
|
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
|
|
|
|
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
|
|
|
|
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)
|
2019-03-13 19:12:23 +01:00
|
|
|
list(APPEND TEST_LIBRARIES syncthingtesthelper)
|
2016-09-21 21:05:31 +02:00
|
|
|
include(TestTarget)
|
2017-07-11 22:40:04 +02:00
|
|
|
|
2021-10-13 00:14:35 +02:00
|
|
|
# avoid running this test in parallel with other tests spawning a Syncthing test instance
|
|
|
|
if (META_MAIN_TEST_NAME)
|
|
|
|
set_tests_properties("${META_MAIN_TEST_NAME}" PROPERTIES RESOURCE_LOCK "syncthingtestinstance")
|
|
|
|
endif ()
|
|
|
|
|
2016-09-30 23:55:25 +02:00
|
|
|
include(Doxygen)
|
|
|
|
include(ConfigHeader)
|