CMakeLists.txt 5.56 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
Laurent Montel's avatar
Laurent Montel committed
2
set(PIM_VERSION "5.16.40")
Volker Krause's avatar
Volker Krause committed
3
project(KItinerary VERSION ${PIM_VERSION})
4

Volker Krause's avatar
Volker Krause committed
5
set(CMAKE_CXX_STANDARD 17)
6
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7
set(KF5_MIN_VERSION "5.78.0")
8

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

include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
13
14
15
if (MSVC)
    add_compile_options(/source-charset:utf-8 /execution-charset:utf-8)
endif()
16
17
18
19
20
21
22
23
24
25
26
include(ECMAddTests)
include(ECMGenerateHeaders)
include(ECMQtDeclareLoggingCategory)
include(ECMSetupVersion)
include(FeatureSummary)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(GenerateExportHeader)

ecm_setup_version(PROJECT VARIABLE_PREFIX KITINERARY
    VERSION_HEADER kitinerary_version.h
27
    PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KPimItineraryConfigVersion.cmake"
28
29
)

30
set(QT_REQUIRED_VERSION "5.14.0")
31
32


33
find_package(Qt5 ${QT_REQUIRED_VERSION} REQUIRED COMPONENTS Gui Qml)
34
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS I18n)
35
36
37
if (NOT ANDROID)
    find_package(SharedMimeInfo 1.3 REQUIRED)
endif()
38

39
40
set(KMIME_VERSION "5.16.40")
set(PIM_PKPASS "5.16.40")
41
42

find_package(KF5Mime ${KMIME_VERSION} CONFIG REQUIRED)
43
44
find_package(KF5CalendarCore ${KF5_MIN_VERSION} CONFIG)
find_package(KF5Contacts ${KF5_MIN_VERSION} CONFIG REQUIRED)
45
find_package(KPimPkPass ${PIM_PKPASS} CONFIG REQUIRED)
46
find_package(Poppler COMPONENTS Core)
Volker Krause's avatar
Volker Krause committed
47
set_package_properties("Poppler" PROPERTIES TYPE OPTIONAL PURPOSE "Support for extraction from PDF booking confirmations.")
48
49
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
50
51
find_package(ZLIB REQUIRED)
set_package_properties("ZLIB" PROPERTIES PURPOSE "Support for decoding UIC 918-3 train tickets.")
52
53
find_package(LibXml2 MODULE)
set_package_properties("LibXml2" PROPERTIES PURPOSE "Support for extraction from HTML booking confirmations." URL "http://libxml.org")
54
55
find_package(PhoneNumber OPTIONAL_COMPONENTS PhoneNumber QUIET)
set_package_properties("PhoneNumber" PROPERTIES PURPOSE "Parsing and geo-coding of phone numbers.")
56
57
find_package(OpenSSL 1.1)
set_package_properties("OpenSSL" PROPERTIES TYPE OPTIONAL PURPOSE "VDV ticket decoding." URL "https://openssl.org")
58
59
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)")
60

61
62
63
if (NOT ANDROID)
    set_package_properties(KF5CalendarCore PROPERTIES TYPE REQUIRED)
    set_package_properties(LibXml2 PROPERTIES TYPE REQUIRED)
64
65
66
67
else()
    # force Poppler on Android, to avoid silent failures on binary factory when its
    # Poppler build broke, which then results in feature regressions in KDE Itinerary
    set_package_properties(Poppler PROPERTIES TYPE REQUIRED)
68
69
endif()

70
if(TARGET Poppler::Core)
71
72
73
74
75
76
77
78
79
80
    # 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)
        message(WARNING "Poppler was not build with ENABLE_UNSTABLE_API_ABI_HEADER - building without PDF support!")
        set(HAVE_POPPLER FALSE)
    else()
        set(HAVE_POPPLER TRUE)
    endif()
endif()
if (HAVE_POPPLER)
Volker Krause's avatar
Volker Krause committed
81
82
83
84
    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})
85
endif()
86

87
if (TARGET ZXing::ZXing OR TARGET ZXing::Core)
88
89
    set(HAVE_ZXING ON)
endif()
90

91
92
93
if (TARGET KF5::CalendarCore)
    set(HAVE_KCAL ON)
endif()
94
95
96
if (LIBXML2_FOUND)
    set(HAVE_LIBXML2 ON)
endif()
97
98
99
if (TARGET PhoneNumber::PhoneNumber)
    set(HAVE_PHONENUMBER ON)
endif()
100
if (TARGET OpenSSL::Crypto)
101
    set(HAVE_OPENSSL_RSA ON)
102
endif()
103

Volker Krause's avatar
Volker Krause committed
104
add_definitions(-DTRANSLATION_DOMAIN=\"kitinerary\")
105

106
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00)
107
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054F00)
108

Laurent Montel's avatar
Laurent Montel committed
109
add_definitions(-DQT_NO_FOREACH)
110
add_definitions(-DQT_NO_KEYWORDS)
111

112
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KPimItinerary")
Volker Krause's avatar
Volker Krause committed
113
114
set(KDE_INSTALL_INCLUDEDIR_PIM ${KDE_INSTALL_INCLUDEDIR}/KPim)

115
116
117
118
119
120
121
122
123
124
125
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()

126
add_subdirectory(src)
Laurent Montel's avatar
Laurent Montel committed
127
128
129
if(BUILD_TESTING)
   add_subdirectory(autotests)
endif()
130
131
132
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)

configure_package_config_file(
133
134
    "${CMAKE_CURRENT_SOURCE_DIR}/KPimItineraryConfig.cmake.in"
    "${CMAKE_CURRENT_BINARY_DIR}/KPimItineraryConfig.cmake"
135
136
137
138
    INSTALL_DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
)

install(FILES
139
140
        "${CMAKE_CURRENT_BINARY_DIR}/KPimItineraryConfig.cmake"
        "${CMAKE_CURRENT_BINARY_DIR}/KPimItineraryConfigVersion.cmake"
141
142
143
        DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
        COMPONENT Devel)

144
install(EXPORT KPimItineraryTargets
145
        DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
146
147
        FILE KPimItineraryTargets.cmake
        NAMESPACE KPim::
148
)
149
install(FILES org_kde_kitinerary.categories  DESTINATION  ${KDE_INSTALL_LOGGINGCATEGORIESDIR})
Volker Krause's avatar
Volker Krause committed
150
151
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kitinerary_version.h
        DESTINATION ${KDE_INSTALL_INCLUDEDIR_PIM} COMPONENT Devel)
152
ki18n_install(po)