CMakeLists.txt 5.25 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1
# SPDX-FileCopyrightText: 2018-2022 Laurent Montel <montel@kde.org>
2
3
4
# SPDX-FileCopyrightText: 2018-2020 Volker Krause <vkrause@kde.org>
# SPDX-License-Identifier: BSD-3-Clause

5
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
6
set(PIM_VERSION "5.20.41")
Volker Krause's avatar
Volker Krause committed
7
project(KItinerary VERSION ${PIM_VERSION})
8

9
set(KF5_MIN_VERSION "5.91.0")
10

11
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
12
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
13

14
include(KDECompilerSettings NO_POLICY_SCOPE)
15
16
17
include(ECMAddTests)
include(ECMGenerateHeaders)
include(ECMQtDeclareLoggingCategory)
18
include(ECMDeprecationSettings)
19
20
21
22
23
include(ECMSetupVersion)
include(FeatureSummary)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(GenerateExportHeader)
Laurent Montel's avatar
Laurent Montel committed
24
25
26
27
28
include(ECMAddQch)


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)")
29
30
31

ecm_setup_version(PROJECT VARIABLE_PREFIX KITINERARY
    VERSION_HEADER kitinerary_version.h
32
    PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KPimItineraryConfigVersion.cmake"
33
34
)

35
set(QT_REQUIRED_VERSION "5.15.2")
36
37


38
find_package(Qt${QT_MAJOR_VERSION} ${QT_REQUIRED_VERSION} REQUIRED COMPONENTS Gui Qml)
39
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS I18n)
40
41
42
if (NOT ANDROID)
    find_package(SharedMimeInfo 1.3 REQUIRED)
endif()
43

Laurent Montel's avatar
Laurent Montel committed
44
45
set(KMIME_VERSION "5.20.40")
set(PIM_PKPASS "5.20.40")
46
47

find_package(KF5Mime ${KMIME_VERSION} CONFIG REQUIRED)
48
49
find_package(KF5CalendarCore ${KF5_MIN_VERSION} CONFIG)
find_package(KF5Contacts ${KF5_MIN_VERSION} CONFIG REQUIRED)
50
find_package(KPimPkPass ${PIM_PKPASS} CONFIG REQUIRED)
51
find_package(Poppler COMPONENTS Core)
52
set_package_properties("Poppler" PROPERTIES TYPE REQUIRED PURPOSE "Support for extraction from PDF booking confirmations.")
53
54
find_package(ZXing CONFIG)
set_package_properties("ZXing" PROPERTIES TYPE OPTIONAL PURPOSE "Support for barcode decoding." URL "https://github.com/nu-book/zxing-cpp")
Volker Krause's avatar
Volker Krause committed
55
56
find_package(ZLIB REQUIRED)
set_package_properties("ZLIB" PROPERTIES PURPOSE "Support for decoding UIC 918-3 train tickets.")
57
58
find_package(LibXml2 MODULE)
set_package_properties("LibXml2" PROPERTIES PURPOSE "Support for extraction from HTML booking confirmations." URL "http://libxml.org")
59
60
find_package(PhoneNumber OPTIONAL_COMPONENTS PhoneNumber QUIET)
set_package_properties("PhoneNumber" PROPERTIES PURPOSE "Parsing and geo-coding of phone numbers.")
61
find_package(OpenSSL 1.1 REQUIRED COMPONENTS Crypto)
62
63
find_package(OsmTools)
set_package_properties(OsmTools PROPERTIES TYPE OPTIONAL PURPOSE "Needed only for regenereating the airport database (ie. you most likely don't need this)")
64

65
66
67
68
69
if (NOT ANDROID)
    set_package_properties(KF5CalendarCore PROPERTIES TYPE REQUIRED)
    set_package_properties(LibXml2 PROPERTIES TYPE REQUIRED)
endif()

70
if(TARGET Poppler::Core)
71
72
73
    # check if we have private Poppler headers
    find_file(HAVE_POPPLER_UNSTABLE_HEADERS "OutputDev.h" PATHS ${Poppler_INCLUDE_DIRS} NO_DEFAULT_PATH)
    if (NOT HAVE_POPPLER_UNSTABLE_HEADERS)
74
        message(FATAL_ERROR "Poppler was not build with ENABLE_UNSTABLE_API_ABI_HEADER!")
75
76
    endif()
endif()
77
78
79
80
string(REGEX MATCH "([0-9]+)\.0*([0-9]+)\.0*([0-9]+)" _match ${Poppler_VERSION})
set(POPPLER_VERSION_MAJOR ${CMAKE_MATCH_1})
set(POPPLER_VERSION_MINOR ${CMAKE_MATCH_2})
set(POPPLER_VERSION_PATCH ${CMAKE_MATCH_3})
81

82
if (TARGET ZXing::ZXing OR TARGET ZXing::Core)
83
84
    set(HAVE_ZXING ON)
endif()
85

86
87
88
if (TARGET KF5::CalendarCore)
    set(HAVE_KCAL ON)
endif()
89
90
91
if (LIBXML2_FOUND)
    set(HAVE_LIBXML2 ON)
endif()
92
93
94
if (TARGET PhoneNumber::PhoneNumber)
    set(HAVE_PHONENUMBER ON)
endif()
95

Volker Krause's avatar
Volker Krause committed
96
add_definitions(-DTRANSLATION_DOMAIN=\"kitinerary\")
97

98
ecm_set_disabled_deprecation_versions(QT 5.15.2 KF 5.94.0)
99

100

101

102
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KPimItinerary")
Volker Krause's avatar
Volker Krause committed
103
104
set(KDE_INSTALL_INCLUDEDIR_PIM ${KDE_INSTALL_INCLUDEDIR}/KPim)

105
option(USE_UNITY_CMAKE_SUPPORT "Use UNITY cmake support (speedup compile time)" OFF)
106

107
set(COMPILE_WITH_UNITY_CMAKE_SUPPORT OFF)
108
if (USE_UNITY_CMAKE_SUPPORT)
109
    set(COMPILE_WITH_UNITY_CMAKE_SUPPORT ON)
110
111
endif()

112
add_subdirectory(src)
Laurent Montel's avatar
Laurent Montel committed
113
114
115
if(BUILD_TESTING)
   add_subdirectory(autotests)
endif()
116
117
118
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)

configure_package_config_file(
119
120
    "${CMAKE_CURRENT_SOURCE_DIR}/KPimItineraryConfig.cmake.in"
    "${CMAKE_CURRENT_BINARY_DIR}/KPimItineraryConfig.cmake"
121
122
123
124
    INSTALL_DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
)

install(FILES
125
126
        "${CMAKE_CURRENT_BINARY_DIR}/KPimItineraryConfig.cmake"
        "${CMAKE_CURRENT_BINARY_DIR}/KPimItineraryConfigVersion.cmake"
127
128
129
        DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
        COMPONENT Devel)

130
install(EXPORT KPimItineraryTargets
131
        DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
132
133
        FILE KPimItineraryTargets.cmake
        NAMESPACE KPim::
134
)
Volker Krause's avatar
Volker Krause committed
135
136
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kitinerary_version.h
        DESTINATION ${KDE_INSTALL_INCLUDEDIR_PIM} COMPONENT Devel)
Laurent Montel's avatar
Laurent Montel committed
137

138
ki18n_install(po)
Laurent Montel's avatar
Laurent Montel committed
139
140
141
142
143
144
145
146
147
if (BUILD_QCH)
    ecm_install_qch_export(
        TARGETS KPimItinerary_QCH
        FILE KPimItineraryQchTargets.cmake
        DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
        COMPONENT Devel
    )
    set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KPimItineraryQchTargets.cmake\")")
endif()