CMakeLists.txt 6.2 KB
Newer Older
Andre Heinecke's avatar
Andre Heinecke committed
1
set(kleopatra_version 3.1.15)
Andre Heinecke's avatar
Andre Heinecke committed
2
# The following is for Windows. Keep in line with kleopatra_version.
Andre Heinecke's avatar
Andre Heinecke committed
3
set(kleopatra_fileversion 3,1,15,0)
4
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
Laurent Montel's avatar
Laurent Montel committed
5
6
project(kleopatra VERSION ${kleopatra_version})

7
8
# The RELEASE_SERVICE_VERSION is used by Gpg4win to add the Gpg4win version
if (NOT RELEASE_SERVICE_VERSION)
9
    set (RELEASE_SERVICE_VERSION "21.07.40")
10
endif()
11

12
option(DISABLE_KWATCHGNUPG "Don't build the kwatchgnupg tool [default=OFF]" OFF)
13

Allen Winter's avatar
Allen Winter committed
14
# Standalone build. Find / include everything necessary.
15
set(KF5_MIN_VERSION "5.82.0")
16
set(KMIME_VERSION "5.17.40")
17
set(LIBKLEO_VERSION "5.17.46")
18
set(QT_REQUIRED_VERSION "5.15.0")
19
set(GPGME_REQUIRED_VERSION "1.13.1")
20
set(BOOST_REQUIRED_VERSION "1.58")
Laurent Montel's avatar
Laurent Montel committed
21

22
23
24
25
26
27
28
29
30
if (WIN32)
  set(KF5_WANT_VERSION "5.70.0")
  set(KMIME_WANT_VERSION "5.12.0")
else ()
  set(KF5_WANT_VERSION ${KF5_MIN_VERSION})
  set(KMIME_WANT_VERSION ${KMIME_VERSION})
endif ()

find_package(ECM ${KF5_WANT_VERSION} CONFIG REQUIRED)
Laurent Montel's avatar
Laurent Montel committed
31
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
32
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
Laurent Montel's avatar
Laurent Montel committed
33
34
35
36
37
38
39
40
41
42
43

include(ECMInstallIcons)
include(ECMSetupVersion)
include(ECMAddTests)
include(GenerateExportHeader)
include(ECMGenerateHeaders)
include(FeatureSummary)
include(CheckFunctionExists)
include(ECMGeneratePriFile)
include(KDEInstallDirs)
include(KDECMakeSettings)
44
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
Laurent Montel's avatar
Laurent Montel committed
45
46
include(ECMAddAppIcon)
include(ECMQtDeclareLoggingCategory)
47

48
# Find KF5 packages
49
50
51
52
53
54
55
56
57
58
59
60
find_package(KF5WidgetsAddons ${KF5_WANT_VERSION} CONFIG REQUIRED)
find_package(KF5ConfigWidgets ${KF5_WANT_VERSION} CONFIG REQUIRED)
find_package(KF5CoreAddons ${KF5_WANT_VERSION} CONFIG REQUIRED)
find_package(KF5Codecs ${KF5_WANT_VERSION} CONFIG REQUIRED)
find_package(KF5Config ${KF5_WANT_VERSION} CONFIG REQUIRED)
find_package(KF5I18n ${KF5_WANT_VERSION} CONFIG REQUIRED)
find_package(KF5IconThemes ${KF5_WANT_VERSION} CONFIG REQUIRED)
find_package(KF5ItemModels ${KF5_WANT_VERSION} CONFIG REQUIRED)
find_package(KF5XmlGui ${KF5_WANT_VERSION} CONFIG REQUIRED)
find_package(KF5WindowSystem ${KF5_WANT_VERSION} CONFIG REQUIRED)
find_package(KF5DocTools ${KF5_WANT_VERSION} CONFIG)
find_package(KF5Crash ${KF5_WANT_VERSION} REQUIRED)
Andre Heinecke's avatar
Andre Heinecke committed
61

62
63
64
65
set_package_properties(KF5DocTools PROPERTIES
    DESCRIPTION "Documentation tools"
    PURPOSE "Required to generate Kleopatra documentation."
    TYPE OPTIONAL)
66

67
68
69
70
# Optional packages
if (WIN32)
  # Only a replacement available for Windows so this
  # is required on other platforms.
71
  find_package(KF5DBusAddons ${KF5_WANT_VERSION} CONFIG)
72
73
  set_package_properties(KF5DBusAddons PROPERTIES DESCRIPTION "Support library to work with DBus"
                         PURPOSE "DBus session integration"
Laurent Montel's avatar
Laurent Montel committed
74
                         URL "https://inqlude.org/libraries/kdbusaddons.html"
75
76
                         TYPE OPTIONAL)
else()
77
  find_package(KF5DBusAddons ${KF5_WANT_VERSION} CONFIG REQUIRED)
78
79
80
81
82
  set(_kleopatra_dbusaddons_libs KF5::DBusAddons)
endif()

set(HAVE_QDBUS ${Qt5DBus_FOUND})

83
find_package(Gpgmepp ${GPGME_REQUIRED_VERSION} CONFIG REQUIRED)
84
85
86
if (Gpgmepp_VERSION VERSION_GREATER_EQUAL "1.15.2")
    set(GPGMEPP_SUPPORTS_TRUST_SIGNATURES 1)
endif()
87
find_package(QGpgme ${GPGME_REQUIRED_VERSION} CONFIG REQUIRED)
88
89
90
if (QGpgme_VERSION VERSION_GREATER_EQUAL "1.15.2")
    set(QGPGME_SUPPORTS_TRUST_SIGNATURES 1)
endif()
91

92
# Kdepimlibs packages
Laurent Montel's avatar
Laurent Montel committed
93
find_package(KF5Libkleo ${LIBKLEO_VERSION} CONFIG REQUIRED)
94
find_package(KF5Mime ${KMIME_WANT_VERSION} CONFIG REQUIRED)
Laurent Montel's avatar
Laurent Montel committed
95

Andre Heinecke's avatar
Andre Heinecke committed
96
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Network PrintSupport)
97

Andre Heinecke's avatar
Andre Heinecke committed
98
find_package(Assuan2 REQUIRED)
99

100
set(CMAKE_CXX_STANDARD 17)
101
set(CMAKE_CXX_STANDARD_REQUIRED ON)
102

103
find_package(Boost ${BOOST_REQUIRED_VERSION} MODULE REQUIRED)
104
105
106

find_path(Boost_TOPOLOGICAL_SORT_DIR NAMES boost/graph/topological_sort.hpp PATHS ${Boost_INCLUDE_DIRS})
if(NOT Boost_TOPOLOGICAL_SORT_DIR)
Laurent Montel's avatar
Laurent Montel committed
107
    message(FATAL_ERROR "The Boost Topological_sort header was NOT found. Should be part of Boost graph module.")
108
endif()
Laurent Montel's avatar
Laurent Montel committed
109

110
111
112
set(kleopatra_release FALSE)

if(NOT kleopatra_release)
Laurent Montel's avatar
Laurent Montel committed
113
114
115
116
117
118
119
120
121
122
123
124
125
    if(GIT_FOUND)
        execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --oneline --format=%h ${CMAKE_CURRENT_SOURCE_DIR}
            WORKING_DIRECTORY ${kdepim_SOURCE_DIR}/kleopatra
            OUTPUT_VARIABLE Kleopatra_WC_REVISION)
        string(REGEX REPLACE "\n" "" Kleopatra_WC_REVISION "${Kleopatra_WC_REVISION}")

        execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --oneline --format=%ci ${CMAKE_CURRENT_SOURCE_DIR}
            WORKING_DIRECTORY ${kdepim_SOURCE_DIR}/kleopatra
            OUTPUT_VARIABLE Kleopatra_WC_LAST_CHANGED_DATE)
        string(REGEX REPLACE " [-0-9:+ ]*\n" "" Kleopatra_WC_LAST_CHANGED_DATE "${Kleopatra_WC_LAST_CHANGED_DATE}")

        set(kleopatra_version "${kleopatra_version}-git${Kleopatra_WC_REVISION} (${Kleopatra_WC_LAST_CHANGED_DATE})")
    endif()
126
127
128
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version-kleopatra.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version-kleopatra.h)
129

130
131
132
include (ConfigureChecks.cmake)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-kleopatra.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kleopatra.h)
133
include_directories(
Laurent Montel's avatar
Laurent Montel committed
134
135
    ${CMAKE_CURRENT_BINARY_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}
136
    ${Boost_INCLUDE_DIRS}
137
    ${ASSUAN2_INCLUDES}
Laurent Montel's avatar
Laurent Montel committed
138
    )
139
140

add_definitions(-D_ASSUAN_ONLY_GPG_ERRORS)
141
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050e00)
142
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055300)
Laurent Montel's avatar
Laurent Montel committed
143
if(CMAKE_COMPILER_IS_GNUCXX)
Laurent Montel's avatar
Laurent Montel committed
144
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces -Wno-parentheses -Wno-ignored-qualifiers")
145
endif()
146
add_definitions(-DQT_NO_EMIT)
147
remove_definitions(-DQT_NO_FOREACH)
148

149
kde_enable_exceptions()
150
option(USE_UNITY_CMAKE_SUPPORT "Use UNITY cmake support (speedup compile time)" OFF)
151

152
set(COMPILE_WITH_UNITY_CMAKE_SUPPORT OFF)
153
if (USE_UNITY_CMAKE_SUPPORT)
154
    set(COMPILE_WITH_UNITY_CMAKE_SUPPORT ON)
155
endif()
156

157

158
add_subdirectory(pics)
159
add_subdirectory(src)
160
161
162

if(BUILD_TESTING)
    add_subdirectory(tests)
163
    add_subdirectory(autotests)
164
endif()
Laurent Montel's avatar
Laurent Montel committed
165

166
ecm_qt_install_logging_categories(
Laurent Montel's avatar
Laurent Montel committed
167
168
169
170
        EXPORT KLEOPATRA
        FILE kleopatra.categories
        DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}
        )
Andre Heinecke's avatar
Andre Heinecke committed
171

Laurent Montel's avatar
Laurent Montel committed
172
ki18n_install(po)
Andre Heinecke's avatar
Andre Heinecke committed
173
if(KF5DocTools_FOUND)
Laurent Montel's avatar
Laurent Montel committed
174
    kdoctools_install(po)
Andre Heinecke's avatar
Andre Heinecke committed
175
176
    add_subdirectory(doc)
endif()
Laurent Montel's avatar
Laurent Montel committed
177
178
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)