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

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

# 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()
11
12
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}")
13
else()
14
    set(KDE_APPLICATIONS_COMPACT_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}${RELEASE_SERVICE_VERSION_MINOR}${RELEASE_SERVICE_VERSION_MICRO}")
15
endif()
16
17
18

set(KLEOPATRA_VERSION_MAJOR "3")
set(KLEOPATRA_VERSION_MINOR "1")
19
set(KLEOPATRA_VERSION_MICRO "20")
20

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

26
project(kleopatra VERSION ${kleopatra_version})
27

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

Allen Winter's avatar
Allen Winter committed
30
# Standalone build. Find / include everything necessary.
31
32
set(KF5_MIN_VERSION "5.88.0")
set(KMIME_VERSION "5.19.40")
33
set(LIBKLEO_VERSION "5.19.46")
34
set(QT_REQUIRED_VERSION "5.15.2")
35
set(GPGME_REQUIRED_VERSION "1.13.1")
36
set(BOOST_REQUIRED_VERSION "1.58")
Laurent Montel's avatar
Laurent Montel committed
37

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

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

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

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

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

set(HAVE_QDBUS ${Qt5DBus_FOUND})

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

112
# Kdepimlibs packages
Laurent Montel's avatar
Laurent Montel committed
113
find_package(KF5Libkleo ${LIBKLEO_VERSION} CONFIG REQUIRED)
114
find_package(KF5Mime ${KMIME_WANT_VERSION} CONFIG REQUIRED)
Laurent Montel's avatar
Laurent Montel committed
115

116
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test Network PrintSupport)
117

Andre Heinecke's avatar
Andre Heinecke committed
118
find_package(Assuan2 REQUIRED)
119

120

121
find_package(Boost ${BOOST_REQUIRED_VERSION} MODULE REQUIRED)
122
123
124

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

128
129
130
set(kleopatra_release FALSE)

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

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

156
157
158
include (ConfigureChecks.cmake)

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

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

175
kde_enable_exceptions()
176
option(USE_UNITY_CMAKE_SUPPORT "Use UNITY cmake support (speedup compile time)" OFF)
177

178
set(COMPILE_WITH_UNITY_CMAKE_SUPPORT OFF)
179
if (USE_UNITY_CMAKE_SUPPORT)
180
    set(COMPILE_WITH_UNITY_CMAKE_SUPPORT ON)
181
endif()
182

183

184
add_subdirectory(pics)
185
add_subdirectory(src)
186
187
188

if(BUILD_TESTING)
    add_subdirectory(tests)
189
    add_subdirectory(autotests)
190
endif()
Laurent Montel's avatar
Laurent Montel committed
191

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

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