CMakeLists.txt 8.66 KB
Newer Older
1
2
# SPDX-FileCopyrightText: none
# SPDX-License-Identifier: BSD-3-Clause
3
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
Laurent Montel's avatar
Laurent Montel committed
4

5
6
7
set(RELEASE_SERVICE_VERSION_MAJOR "22")
set(RELEASE_SERVICE_VERSION_MINOR "03")
set(RELEASE_SERVICE_VERSION_MICRO "70")
8
9
10
11
12

# The RELEASE_SERVICE_VERSION is used by Gpg4win to add the Gpg4win version
if (NOT RELEASE_SERVICE_VERSION)
    set(RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
endif()
13
14
if(RELEASE_SERVICE_VERSION_MICRO LESS 10)
    set(KDE_APPLICATIONS_COMPACT_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}${RELEASE_SERVICE_VERSION_MINOR}0${RELEASE_SERVICE_VERSION_MICRO}")
15
else()
16
    set(KDE_APPLICATIONS_COMPACT_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}${RELEASE_SERVICE_VERSION_MINOR}${RELEASE_SERVICE_VERSION_MICRO}")
17
endif()
18
19
20

set(KLEOPATRA_VERSION_MAJOR "3")
set(KLEOPATRA_VERSION_MINOR "1")
Andre Heinecke's avatar
Andre Heinecke committed
21
set(KLEOPATRA_VERSION_MICRO "22")
22

23
set(kleopatra_version "${KLEOPATRA_VERSION_MAJOR}.${KLEOPATRA_VERSION_MINOR}.${KLEOPATRA_VERSION_MICRO}.${KDE_APPLICATIONS_COMPACT_VERSION}")
24
# The following is for Windows
25
26
set(kleopatra_version_win "${KLEOPATRA_VERSION_MAJOR}.${KLEOPATRA_VERSION_MINOR}.${KLEOPATRA_VERSION_MICRO}")
set(kleopatra_fileversion_win "${KLEOPATRA_VERSION_MAJOR},${KLEOPATRA_VERSION_MINOR},${KLEOPATRA_VERSION_MICRO},0")
27

28
project(kleopatra VERSION ${kleopatra_version})
29

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

Allen Winter's avatar
Allen Winter committed
32
# Standalone build. Find / include everything necessary.
33
set(KF5_MIN_VERSION "5.90.0")
34
set(KMIME_VERSION "5.19.40")
35
set(LIBKLEO_VERSION "5.19.49")
36
set(QT_REQUIRED_VERSION "5.15.2")
Ingo Klöcker's avatar
Ingo Klöcker committed
37
set(GPGME_REQUIRED_VERSION "1.15.0")
38
set(BOOST_REQUIRED_VERSION "1.58")
Laurent Montel's avatar
Laurent Montel committed
39

40
41
42
43
44
45
46
47
48
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
49
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
50
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
Laurent Montel's avatar
Laurent Montel committed
51
52
53
54
55
56
57
58
59
60

include(ECMInstallIcons)
include(ECMSetupVersion)
include(ECMAddTests)
include(GenerateExportHeader)
include(ECMGenerateHeaders)
include(FeatureSummary)
include(CheckFunctionExists)
include(KDEInstallDirs)
include(KDECMakeSettings)
61
include(KDECompilerSettings NO_POLICY_SCOPE)
Laurent Montel's avatar
Laurent Montel committed
62
63
include(ECMAddAppIcon)
include(ECMQtDeclareLoggingCategory)
64

65
# Find KF5 packages
66
67
68
69
70
71
72
73
74
75
76
77
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
78

79
80
81
82
set_package_properties(KF5DocTools PROPERTIES
    DESCRIPTION "Documentation tools"
    PURPOSE "Required to generate Kleopatra documentation."
    TYPE OPTIONAL)
83

84
85
86
87
# Optional packages
if (WIN32)
  # Only a replacement available for Windows so this
  # is required on other platforms.
88
  find_package(KF5DBusAddons ${KF5_WANT_VERSION} CONFIG)
89
90
  set_package_properties(KF5DBusAddons PROPERTIES DESCRIPTION "Support library to work with DBus"
                         PURPOSE "DBus session integration"
Laurent Montel's avatar
Laurent Montel committed
91
                         URL "https://inqlude.org/libraries/kdbusaddons.html"
92
93
                         TYPE OPTIONAL)
else()
94
  find_package(KF5DBusAddons ${KF5_WANT_VERSION} CONFIG REQUIRED)
95
96
97
  set(_kleopatra_dbusaddons_libs KF5::DBusAddons)
endif()

98
set(HAVE_QDBUS ${Qt${QT_MAJOR_VERSION}DBus_FOUND})
99

100
find_package(Gpgmepp ${GPGME_REQUIRED_VERSION} CONFIG REQUIRED)
101
if (Gpgmepp_VERSION VERSION_GREATER_EQUAL "1.16.0")
102
103
    set(GPGMEPP_SUPPORTS_TRUST_SIGNATURES 1)
endif()
104
find_package(QGpgme ${GPGME_REQUIRED_VERSION} CONFIG REQUIRED)
105
if (QGpgme_VERSION VERSION_GREATER_EQUAL "1.16.0")
106
    set(QGPGME_SUPPORTS_TRUST_SIGNATURES 1)
107
    set(QGPGME_SUPPORTS_SIGNATURE_EXPIRATION 1)
108
endif()
109
110
if (QGpgme_VERSION VERSION_GREATER_EQUAL "1.16.1")
    set(QGPGME_SUPPORTS_CHANGING_EXPIRATION_OF_COMPLETE_KEY 1)
111
    set(QGPGME_CRYPTOCONFIGENTRY_HAS_DEFAULT_VALUE 1)
112
    set(QGPGME_SUPPORTS_WKDLOOKUP 1)
113
    set(QGPGME_SUPPORTS_IMPORT_WITH_FILTER 1)
114
    set(QGPGME_SUPPORTS_IMPORT_WITH_KEY_ORIGIN 1)
115
    set(QGPGME_SUPPORTS_SECRET_KEY_EXPORT 1)
Ingo Klöcker's avatar
Ingo Klöcker committed
116
    set(QGPGME_SUPPORTS_SECRET_SUBKEY_EXPORT 1)
117
    set(QGPGME_SUPPORTS_RECEIVING_KEYS_BY_KEY_ID 1)
118
endif()
119

120
# Kdepimlibs packages
Laurent Montel's avatar
Laurent Montel committed
121
find_package(KF5Libkleo ${LIBKLEO_VERSION} CONFIG REQUIRED)
122
find_package(KF5Mime ${KMIME_WANT_VERSION} CONFIG REQUIRED)
Laurent Montel's avatar
Laurent Montel committed
123

124
find_package(Qt${QT_MAJOR_VERSION} ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Network PrintSupport)
125

Andre Heinecke's avatar
Andre Heinecke committed
126
find_package(Assuan2 REQUIRED)
127

128

129
find_package(Boost ${BOOST_REQUIRED_VERSION} MODULE REQUIRED)
130
131
132

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
133
    message(FATAL_ERROR "The Boost Topological_sort header was NOT found. Should be part of Boost graph module.")
134
endif()
Laurent Montel's avatar
Laurent Montel committed
135

136
137
138
set(kleopatra_release FALSE)

if(NOT kleopatra_release)
139
    find_package(Git)
Laurent Montel's avatar
Laurent Montel committed
140
    if(GIT_FOUND)
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
        execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse
                        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                        RESULT_VARIABLE rc
                        ERROR_QUIET)
        if(rc EQUAL 0)
            execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --oneline --format=%h ${CMAKE_CURRENT_SOURCE_DIR}
                WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                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 ${CMAKE_CURRENT_SOURCE_DIR}
                OUTPUT_VARIABLE Kleopatra_WC_LAST_CHANGED_DATE)
            string(REGEX REPLACE "^([0-9]+)-([0-9]+)-([0-9]+)T([0-9]+):([0-9]+):([0-9]+).*$" "\\1\\2\\3T\\4\\5\\6"
                   Kleopatra_WC_LAST_CHANGED_DATE "${Kleopatra_WC_LAST_CHANGED_DATE}")

            set(kleopatra_version "${kleopatra_version}+git${Kleopatra_WC_LAST_CHANGED_DATE}~${Kleopatra_WC_REVISION}")
        endif()
Laurent Montel's avatar
Laurent Montel committed
159
    endif()
160
161
162
endif()

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

164
165
166
include (ConfigureChecks.cmake)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-kleopatra.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kleopatra.h)
167
include_directories(
Laurent Montel's avatar
Laurent Montel committed
168
169
    ${CMAKE_CURRENT_BINARY_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}
170
    ${Boost_INCLUDE_DIRS}
171
    ${ASSUAN2_INCLUDES}
Laurent Montel's avatar
Laurent Montel committed
172
    )
173
174

add_definitions(-D_ASSUAN_ONLY_GPG_ERRORS)
175
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050e00)
176
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055B00)
Laurent Montel's avatar
Laurent Montel committed
177
if(CMAKE_COMPILER_IS_GNUCXX)
Laurent Montel's avatar
Laurent Montel committed
178
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces -Wno-parentheses -Wno-ignored-qualifiers")
179
endif()
180
add_definitions(-DQT_NO_EMIT)
181
remove_definitions(-DQT_NO_FOREACH)
182

183
184
185
186
187
188
189
190
191
192
193
194
# Disable the use of QStringBuilder for operator+ to prevent crashes when
# returning the result of concatenating string temporaries in lambdas. We do
# this for example in some std::transform expressions.
# This is a known issue: https://bugreports.qt.io/browse/QTBUG-47066
# Alternatively, one would always have to remember to force the lambdas to
# return a QString instead of QStringBuilder, but that's just too easy to
# forget and, unfortunately, the compiler doesn't issue a warning if one forgets
# this. So, it's just too dangerous.
# One can still use QStringBuilder explicitly with the operator% if necessary.
remove_definitions(-DQT_USE_FAST_OPERATOR_PLUS)
remove_definitions(-DQT_USE_QSTRINGBUILDER)

195
kde_enable_exceptions()
196
option(USE_UNITY_CMAKE_SUPPORT "Use UNITY cmake support (speedup compile time)" OFF)
197

198
set(COMPILE_WITH_UNITY_CMAKE_SUPPORT OFF)
199
if (USE_UNITY_CMAKE_SUPPORT)
200
    set(COMPILE_WITH_UNITY_CMAKE_SUPPORT ON)
201
endif()
202

203

204
add_subdirectory(pics)
205
add_subdirectory(src)
206
207
208

if(BUILD_TESTING)
    add_subdirectory(tests)
209
    add_subdirectory(autotests)
210
endif()
Laurent Montel's avatar
Laurent Montel committed
211

212
ecm_qt_install_logging_categories(
Laurent Montel's avatar
Laurent Montel committed
213
214
215
216
        EXPORT KLEOPATRA
        FILE kleopatra.categories
        DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}
        )
Andre Heinecke's avatar
Andre Heinecke committed
217

Laurent Montel's avatar
Laurent Montel committed
218
ki18n_install(po)
Andre Heinecke's avatar
Andre Heinecke committed
219
if(KF5DocTools_FOUND)
Laurent Montel's avatar
Laurent Montel committed
220
    kdoctools_install(po)
Andre Heinecke's avatar
Andre Heinecke committed
221
222
    add_subdirectory(doc)
endif()
Laurent Montel's avatar
Laurent Montel committed
223
224
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)