CMakeLists.txt 3.2 KB
Newer Older
1
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
Laurent Montel's avatar
Laurent Montel committed
2
set(PIM_VERSION "5.19.2")
Gregory Schlomoff's avatar
Gregory Schlomoff committed
3

4
project(KSMTP VERSION ${PIM_VERSION})
Gregory Schlomoff's avatar
Gregory Schlomoff committed
5

6

7
# ECM setup
8
set(KF5_MIN_VERSION "5.87.0")
9

10
find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED)
11
12
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})

13
14
include(KDEInstallDirs)
include(KDECMakeSettings)
15
include(KDECompilerSettings NO_POLICY_SCOPE)
16

17
18
19
include(GenerateExportHeader)
include(ECMGenerateHeaders)
include(ECMGeneratePriFile)
20

21
22
include(ECMSetupVersion)
include(FeatureSummary)
23
include(KDEGitCommitHooks)
24
25
26
27
include(KDEClangFormat)
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h *.c)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})

28
include(ECMQtDeclareLoggingCategory)
29

Laurent Montel's avatar
Laurent Montel committed
30
include(ECMAddQch)
Gregory Schlomoff's avatar
Gregory Schlomoff committed
31
32


Laurent Montel's avatar
Laurent Montel committed
33
34
35
option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF)
add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)")

36
set(KSMTP_LIB_VERSION ${PIM_VERSION})
37
set(QT_REQUIRED_VERSION "5.15.2")
38
39
40
41
42
43
44
45
ecm_setup_version(PROJECT VARIABLE_PREFIX KSMTP
    VERSION_HEADER ${KSMTP_BINARY_DIR}/ksmtp_version.h
    PACKAGE_VERSION_FILE ${KSMTP_BINARY_DIR}/KPimSMTPConfigVersion.cmake
    SOVERSION 5
)


############ Find packages ############
Daniel Vrátil's avatar
Daniel Vrátil committed
46
47
find_package(Qt5Network ${QT_REQUIRED_VERSION} REQUIRED)

48
49
50
find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(KF5I18n ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG REQUIRED)
Daniel Vrátil's avatar
Daniel Vrátil committed
51

52
find_package(Sasl2)
53
set_package_properties(Sasl2 PROPERTIES TYPE REQUIRED)
54

55
56
########### CMake Config Files ############
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KPimSMTP")
Gregory Schlomoff's avatar
Gregory Schlomoff committed
57

58
59
60
61
configure_package_config_file(
    "${KSMTP_SOURCE_DIR}/KPimSMTPConfig.cmake.in"
    "${KSMTP_BINARY_DIR}/KPimSMTPConfig.cmake"
    INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
Gregory Schlomoff's avatar
Gregory Schlomoff committed
62
63
)

Laurent Montel's avatar
Laurent Montel committed
64
add_definitions(-DTRANSLATION_DOMAIN=\"libksmtp5\")
65
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f02)
66
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055800)
67

68

69
option(USE_UNITY_CMAKE_SUPPORT "Use UNITY cmake support (speedup compile time)" OFF)
70

71
set(COMPILE_WITH_UNITY_CMAKE_SUPPORT OFF)
Laurent Montel's avatar
Laurent Montel committed
72
if (USE_UNITY_CMAKE_SUPPORT)
73
    set(COMPILE_WITH_UNITY_CMAKE_SUPPORT ON)
74
endif()
Laurent Montel's avatar
Laurent Montel committed
75

76

77
78
79
80
81
########### Targets ###########
add_subdirectory(src)

if (BUILD_TESTING)
    add_subdirectory(autotests)
82
    add_subdirectory(tests)
83
84
85
86
87
88
89
90
endif ()

########### Install Files ############
install(FILES
    "${KSMTP_BINARY_DIR}/KPimSMTPConfig.cmake"
    "${KSMTP_BINARY_DIR}/KPimSMTPConfigVersion.cmake"
    DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
    COMPONENT Devel
Gregory Schlomoff's avatar
Gregory Schlomoff committed
91
92
)

93
install(EXPORT KPimSMTPTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KPimSMTPTargets.cmake NAMESPACE KPim::)
Gregory Schlomoff's avatar
Gregory Schlomoff committed
94

95
96
97
98
install(FILES
    ${KSMTP_BINARY_DIR}/ksmtp_version.h
    DESTINATION ${KDE_INSTALL_INCLUDEDIR}/KPim COMPONENT Devel
)
Gregory Schlomoff's avatar
Gregory Schlomoff committed
99

Laurent Montel's avatar
Laurent Montel committed
100
101
102
103
104
105
106
107
108
109
if (BUILD_QCH)
    ecm_install_qch_export(
        TARGETS KPimSMTP_QCH
        FILE KPimSMTPQchTargets.cmake
        DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
        COMPONENT Devel
    )
    set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KPimSMTPQchTargets.cmake\")")
endif()

110
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
111
ki18n_install(po)
112
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)