CMakeLists.txt 6.25 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)
Laurent Montel's avatar
Laurent Montel committed
4
cmake_minimum_required(VERSION 3.5 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)
Laurent Montel's avatar
Laurent Montel committed
9
    set (RELEASE_SERVICE_VERSION "21.03.80")
10
endif()
11

12
option(FORCE_DISABLE_KCMUTILS "Force building Kleopatra without KCMUtils. Doing this will disable configuration KCM Plugins. [default=OFF]" OFF)
13
option(DISABLE_KWATCHGNUPG "Don't build the kwatchgnupg tool [default=OFF]" OFF)
14

Allen Winter's avatar
Allen Winter committed
15
# Standalone build. Find / include everything necessary.
16
set(KF5_MIN_VERSION "5.77.0")
17
set(KMIME_VERSION "5.16.40")
18
set(LIBKLEO_VERSION "5.16.42")
19
set(QT_REQUIRED_VERSION "5.14.0")
20
set(GPGME_REQUIRED_VERSION "1.13.1")
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

Laurent Montel's avatar
Laurent Montel committed
35 36 37
include(ECMInstallIcons)
include(ECMSetupVersion)
include(ECMAddTests)
38

Laurent Montel's avatar
Laurent Montel committed
39 40
include(GenerateExportHeader)
include(ECMGenerateHeaders)
41

Laurent Montel's avatar
Laurent Montel committed
42 43 44 45 46 47
include(FeatureSummary)
include(CheckFunctionExists)
include(ECMGeneratePriFile)

include(KDEInstallDirs)
include(KDECMakeSettings)
48
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
Laurent Montel's avatar
Laurent Montel committed
49 50
include(ECMAddAppIcon)
include(ECMQtDeclareLoggingCategory)
51

52
# Find KF5 packages
53
if (NOT FORCE_DISABLE_KCMUTILS)
54
  find_package(KF5KCMUtils ${KF5_WANT_VERSION} CONFIG REQUIRED)
55
endif()
56 57 58 59 60 61 62 63 64 65 66 67
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
68 69

set_package_properties(KF5DocTools PROPERTIES DESCRIPTION "Documentation tools" TYPE OPTIONAL PURPOSE "Required to generate Kleopatra documentation.")
70

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

set(HAVE_QDBUS ${Qt5DBus_FOUND})

87 88
find_package(Gpgmepp ${GPGME_REQUIRED_VERSION} CONFIG REQUIRED)
find_package(QGpgme ${GPGME_REQUIRED_VERSION} CONFIG REQUIRED)
89

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

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

Andre Heinecke's avatar
Andre Heinecke committed
96
find_package(Assuan2 REQUIRED)
97

98
set(HAVE_KCMUTILS ${KF5KCMUtils_FOUND})
99 100
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
101 102


103 104 105 106
find_package(Boost 1.34.0 REQUIRED)

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 136
    ${CMAKE_CURRENT_BINARY_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${Boost_INCLUDE_DIR}
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=0x050f00)
142
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054E00)
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

148
kde_enable_exceptions()
149 150 151 152 153 154 155 156 157 158
option(USE_UNITY_CMAKE_SUPPORT "Use UNITY cmake support (speedup compile time)" FALSE)

set(COMPILE_WITH_UNITY_CMAKE_SUPPORT false)
if (USE_UNITY_CMAKE_SUPPORT)
    if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
        message(STATUS "CMAKE version is less than 3.16.0 . We can't use cmake unify build support")
    else()
        set(COMPILE_WITH_UNITY_CMAKE_SUPPORT true)
    endif()
endif()
159

160
add_subdirectory(pics)
161
add_subdirectory(src)
162 163 164

if(BUILD_TESTING)
    add_subdirectory(tests)
165
    add_subdirectory(autotests)
166
endif()
Laurent Montel's avatar
Laurent Montel committed
167

168
ecm_qt_install_logging_categories(
Laurent Montel's avatar
Laurent Montel committed
169 170 171 172
        EXPORT KLEOPATRA
        FILE kleopatra.categories
        DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}
        )
Andre Heinecke's avatar
Andre Heinecke committed
173 174 175 176

if(KF5DocTools_FOUND)
    add_subdirectory(doc)
endif()