CMakeLists.txt 7.54 KB
Newer Older
1
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
Laurent Montel's avatar
Laurent Montel committed
2

3
# The RELEASE_SERVICE_VERSION is used by Gpg4win to add the Gpg4win version
4
set(RELEASE_SERVICE_VERSION_MAJOR "21")
5
set(RELEASE_SERVICE_VERSION_MINOR "11")
6
7
8
9
set(RELEASE_SERVICE_VERSION_MICRO "40")
set(RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
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}")
10
else()
11
    set(KDE_APPLICATIONS_COMPACT_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}${RELEASE_SERVICE_VERSION_MINOR}${RELEASE_SERVICE_VERSION_MICRO}")
12
endif()
13
14
15

set(KLEOPATRA_VERSION_MAJOR "3")
set(KLEOPATRA_VERSION_MINOR "1")
Andre Heinecke's avatar
Andre Heinecke committed
16
set(KLEOPATRA_VERSION_MICRO "17")
17

18
set(kleopatra_version "${KLEOPATRA_VERSION_MAJOR}.${KLEOPATRA_VERSION_MINOR}.${KLEOPATRA_VERSION_MICRO}.${KDE_APPLICATIONS_COMPACT_VERSION}")
19
# The following is for Windows
20
21
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")
22

23
project(kleopatra VERSION ${kleopatra_version})
24

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

Allen Winter's avatar
Allen Winter committed
27
# Standalone build. Find / include everything necessary.
28
set(KF5_MIN_VERSION "5.86.0")
29
30
set(KMIME_VERSION "5.18.40")
set(LIBKLEO_VERSION "5.18.40")
31
set(QT_REQUIRED_VERSION "5.15.2")
32
set(GPGME_REQUIRED_VERSION "1.13.1")
33
set(BOOST_REQUIRED_VERSION "1.58")
Laurent Montel's avatar
Laurent Montel committed
34

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

include(ECMInstallIcons)
include(ECMSetupVersion)
include(ECMAddTests)
include(GenerateExportHeader)
include(ECMGenerateHeaders)
include(FeatureSummary)
include(CheckFunctionExists)
include(KDEInstallDirs)
include(KDECMakeSettings)
56
include(KDECompilerSettings NO_POLICY_SCOPE)
Laurent Montel's avatar
Laurent Montel committed
57
58
include(ECMAddAppIcon)
include(ECMQtDeclareLoggingCategory)
59

60
# Find KF5 packages
61
62
63
64
65
66
67
68
69
70
71
72
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
73

74
75
76
77
set_package_properties(KF5DocTools PROPERTIES
    DESCRIPTION "Documentation tools"
    PURPOSE "Required to generate Kleopatra documentation."
    TYPE OPTIONAL)
78

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

set(HAVE_QDBUS ${Qt5DBus_FOUND})

95
find_package(Gpgmepp ${GPGME_REQUIRED_VERSION} CONFIG REQUIRED)
96
if (Gpgmepp_VERSION VERSION_GREATER_EQUAL "1.16.0")
97
98
    set(GPGMEPP_SUPPORTS_TRUST_SIGNATURES 1)
endif()
99
find_package(QGpgme ${GPGME_REQUIRED_VERSION} CONFIG REQUIRED)
100
if (QGpgme_VERSION VERSION_GREATER_EQUAL "1.16.0")
101
    set(QGPGME_SUPPORTS_TRUST_SIGNATURES 1)
102
    set(QGPGME_SUPPORTS_SIGNATURE_EXPIRATION 1)
103
endif()
104
105
if (QGpgme_VERSION VERSION_GREATER_EQUAL "1.16.1")
    set(QGPGME_SUPPORTS_CHANGING_EXPIRATION_OF_COMPLETE_KEY 1)
106
    set(QGPGME_CRYPTOCONFIGENTRY_HAS_DEFAULT_VALUE 1)
107
endif()
108

109
# Kdepimlibs packages
Laurent Montel's avatar
Laurent Montel committed
110
find_package(KF5Libkleo ${LIBKLEO_VERSION} CONFIG REQUIRED)
111
find_package(KF5Mime ${KMIME_WANT_VERSION} CONFIG REQUIRED)
Laurent Montel's avatar
Laurent Montel committed
112

113
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Network PrintSupport)
114

Andre Heinecke's avatar
Andre Heinecke committed
115
find_package(Assuan2 REQUIRED)
116

117

118
find_package(Boost ${BOOST_REQUIRED_VERSION} MODULE REQUIRED)
119
120
121

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

125
126
127
set(kleopatra_release FALSE)

if(NOT kleopatra_release)
128
    find_package(Git)
Laurent Montel's avatar
Laurent Montel committed
129
    if(GIT_FOUND)
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
        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
148
    endif()
149
150
151
endif()

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

153
154
155
include (ConfigureChecks.cmake)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-kleopatra.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kleopatra.h)
156
include_directories(
Laurent Montel's avatar
Laurent Montel committed
157
158
    ${CMAKE_CURRENT_BINARY_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}
159
    ${Boost_INCLUDE_DIRS}
160
    ${ASSUAN2_INCLUDES}
Laurent Montel's avatar
Laurent Montel committed
161
    )
162
163

add_definitions(-D_ASSUAN_ONLY_GPG_ERRORS)
164
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050e00)
165
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055700)
Laurent Montel's avatar
Laurent Montel committed
166
if(CMAKE_COMPILER_IS_GNUCXX)
Laurent Montel's avatar
Laurent Montel committed
167
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces -Wno-parentheses -Wno-ignored-qualifiers")
168
endif()
169
add_definitions(-DQT_NO_EMIT)
170
remove_definitions(-DQT_NO_FOREACH)
171

172
kde_enable_exceptions()
173
option(USE_UNITY_CMAKE_SUPPORT "Use UNITY cmake support (speedup compile time)" OFF)
174

175
set(COMPILE_WITH_UNITY_CMAKE_SUPPORT OFF)
176
if (USE_UNITY_CMAKE_SUPPORT)
177
    set(COMPILE_WITH_UNITY_CMAKE_SUPPORT ON)
178
endif()
179

180

181
add_subdirectory(pics)
182
add_subdirectory(src)
183
184
185

if(BUILD_TESTING)
    add_subdirectory(tests)
186
    add_subdirectory(autotests)
187
endif()
Laurent Montel's avatar
Laurent Montel committed
188

189
ecm_qt_install_logging_categories(
Laurent Montel's avatar
Laurent Montel committed
190
191
192
193
        EXPORT KLEOPATRA
        FILE kleopatra.categories
        DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}
        )
Andre Heinecke's avatar
Andre Heinecke committed
194

Laurent Montel's avatar
Laurent Montel committed
195
ki18n_install(po)
Andre Heinecke's avatar
Andre Heinecke committed
196
if(KF5DocTools_FOUND)
Laurent Montel's avatar
Laurent Montel committed
197
    kdoctools_install(po)
Andre Heinecke's avatar
Andre Heinecke committed
198
199
    add_subdirectory(doc)
endif()
Laurent Montel's avatar
Laurent Montel committed
200
201
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)