forked from qxmpp-project/qxmpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
145 lines (117 loc) · 3.92 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# SPDX-FileCopyrightText: 2017 Niels Ole Salscheider <niels_ole@salscheider-online.de>
#
# SPDX-License-Identifier: CC0-1.0
cmake_minimum_required(VERSION 3.7)
project(qxmpp VERSION 1.6.0)
set(SO_VERSION 4)
# C++ standard settings:
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/modules")
# Qt
if(NOT DEFINED QT_VERSION_MAJOR)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network Xml)
endif()
message("-- Choosing Qt ${QT_VERSION_MAJOR}")
find_package(Qt${QT_VERSION_MAJOR} 5.15.0 REQUIRED COMPONENTS Core Network Xml)
# QCA (optional)
find_package(Qca-qt${QT_VERSION_MAJOR} QUIET)
if(${QT_VERSION_MAJOR} EQUAL 6)
find_package(Qt6Core5Compat)
endif()
include(GNUInstallDirs)
option(BUILD_SHARED "Build shared library" ON)
option(BUILD_TESTS "Build tests." ON)
option(BUILD_INTERNAL_TESTS "Build internal tests." OFF)
option(BUILD_DOCUMENTATION "Build API documentation." OFF)
option(BUILD_EXAMPLES "Build examples." ON)
option(BUILD_OMEMO "Build the OMEMO module" OFF)
option(WITH_GSTREAMER "Build with GStreamer support for Jingle" OFF)
option(WITH_QCA "Build with QCA for OMEMO or encrypted file sharing" ${Qca-qt${QT_VERSION_MAJOR}_FOUND})
set(QXMPP_TARGET QXmppQt${QT_VERSION_MAJOR})
set(QXMPPOMEMO_TARGET QXmppOmemoQt${QT_VERSION_MAJOR})
add_definitions(
-DQT_DISABLE_DEPRECATED_BEFORE=0x050F00
-DQURL_NO_CAST_FROM_STRING
-DQT_NO_CAST_TO_ASCII
-DQT_NO_FOREACH
-DQT_NO_KEYWORDS
)
if(BUILD_OMEMO)
add_definitions(-DBUILD_OMEMO)
# libomemo-c
find_package(PkgConfig REQUIRED)
pkg_check_modules(OmemoC REQUIRED IMPORTED_TARGET libomemo-c)
# QCA
if(NOT WITH_QCA)
message(FATAL_ERROR "OMEMO requires QCA (Qt Cryptographic Architecture)")
endif()
endif()
if(WITH_QCA)
add_definitions(-DWITH_QCA)
endif()
add_subdirectory(src)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
if(BUILD_DOCUMENTATION)
add_subdirectory(doc)
endif()
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
include(CMakePackageConfigHelpers)
# Normal QXmppQt5/6 package
configure_package_config_file(
QXmppConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${QXMPP_TARGET}Config.cmake
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${QXMPP_TARGET}"
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${QXMPP_TARGET}ConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${QXMPP_TARGET}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${QXMPP_TARGET}ConfigVersion.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${QXMPP_TARGET}"
COMPONENT Devel
)
# QXmpp package with Qt version autodetect
configure_package_config_file(
cmake/QXmppQtAutoConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/QXmppConfig.cmake
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/QXmpp"
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/QXmppConfig.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/QXmpp"
COMPONENT Devel
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/QXmppQtAutoConfigVersion.cmake
RENAME QXmppConfigVersion.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/QXmpp"
COMPONENT Devel
)
# Generate QXmppQt5/6.pc
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/qxmpp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${QXMPP_TARGET}.pc @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${QXMPP_TARGET}.pc
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
COMPONENT Devel
)
# "qxmpp.pc" for backwards-compatibility
if(QT_VERSION_MAJOR EQUAL 5)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/qxmpp_legacy.pc.in ${CMAKE_CURRENT_BINARY_DIR}/qxmpp.pc @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/qxmpp.pc
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
COMPONENT Devel
)
endif()