Debian Codegraph @

CMakeLists.txt

raw ◀ ▶
Source reconstructed at patch state 0 of 4 — not the installed (fully patched) source.
4 Debian patches touch this file
1 cmake_minimum_required(VERSION 3.13...3.21)
2
3 option(APPVEYOR_BUILD "Build on appveyor" OFF)
4 option(CI_BUILD "Set when building in CI. Enables -Werror where possible" OFF)
5 option(ASAN "Compile with address sanitizers" OFF)
6 option(QML_DEBUGGING "Enable qml debugging" OFF)
7 if(UNIX AND NOT APPLE)
8 option(MAN "Build man page" ON)
9 else()
10 option(MAN "Build man page" OFF)
11 endif()
12 option(FLATPAK "Set this only if Nheko is built as a flatpak" OFF)
13 option(JSON_ImplicitConversions "Disable implicit conversions in nlohmann/json" ON)
14
15 set(
16 CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/toolchain.cmake"
17 CACHE
18 FILEPATH "Default toolchain"
19 )
20 set(CMAKE_CXX_STANDARD 20 CACHE STRING "C++ standard")
21 set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "Require C++ standard to be supported")
22 set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "compile as PIC by default")
23 set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "macos deployment target")
24
25 option(HUNTER_ENABLED "Enable Hunter package manager" OFF)
26 include("cmake/HunterGate.cmake")
27 HunterGate(
28 URL "https://github.com/cpp-pm/hunter/archive/v0.26.1.tar.gz"
29 SHA1 "e41ac7a18c49b35ebac99ff2b5244317b2638a65"
30 LOCAL
31 )
32
33 macro(hunter_add_package_safe)
34 set(pkg_temp_backup_libdir "$ENV{PKG_CONFIG_LIBDIR}")
35 set(pkg_temp_backup_path "$ENV{PKG_CONFIG_PATH}")
36 hunter_add_package(${ARGV})
37 if("${pkg_temp_backup_path}" STREQUAL "")
38 unset(ENV{PKG_CONFIG_PATH})
39 else()
40 set(ENV{PKG_CONFIG_PATH} "${pkg_temp_backup_path}")
41 endif()
42 if("${pkg_temp_backup_libdir}" STREQUAL "")
43 unset(ENV{PKG_CONFIG_LIBDIR})
44 else()
45 set(ENV{PKG_CONFIG_LIBDIR} "${pkg_temp_backup_libdir}")
46 endif()
47 message("pkg_conf_path: '$ENV{PKG_CONFIG_PATH}', pkg_conf_libdir: '$ENV{PKG_CONFIG_LIBDIR}'")
48 endmacro()
49
50 project(nheko LANGUAGES CXX C)
51
52 option(USE_BUNDLED_SPDLOG "Use the bundled version of spdlog." ${HUNTER_ENABLED})
53 option(USE_BUNDLED_FMT "Use the bundled version of {fmt}." ${HUNTER_ENABLED})
54 option(USE_BUNDLED_OLM "Use the bundled version of libolm." ${HUNTER_ENABLED})
55 option(USE_BUNDLED_GTEST "Use the bundled version of Google Test." ${HUNTER_ENABLED})
56 option(USE_BUNDLED_CMARK "Use the bundled version of cmark." ${HUNTER_ENABLED})
57 option(USE_BUNDLED_JSON "Use the bundled version of nlohmann json." ${HUNTER_ENABLED})
58 option(USE_BUNDLED_OPENSSL "Use the bundled version of OpenSSL." OFF)
59 option(USE_BUNDLED_MTXCLIENT "Use the bundled version of the Matrix Client library." ${HUNTER_ENABLED})
60 option(USE_BUNDLED_LMDB "Use the bundled version of lmdb." ${HUNTER_ENABLED})
61 option(USE_BUNDLED_LMDBXX "Use the bundled version of lmdb++." ${HUNTER_ENABLED})
62 option(USE_BUNDLED_QTKEYCHAIN "Use the bundled version of Qt6Keychain." ${HUNTER_ENABLED})
63 option(USE_BUNDLED_COEURL "Use a bundled version of the Curl wrapper"
64 ${HUNTER_ENABLED})
65 option(USE_BUNDLED_LIBEVENT "Use the bundled version of libevent." ${HUNTER_ENABLED})
66 option(USE_BUNDLED_LIBCURL "Use the bundled version of libcurl." ${HUNTER_ENABLED})
67 option(USE_BUNDLED_RE2 "Use the bundled version of re2." ${HUNTER_ENABLED})
68 option(USE_BUNDLED_KDSINGLEAPPLICATION "Use the bundled version of KDSingleApplication." ${HUNTER_ENABLED})
69 option(USE_BUNDLED_CPPHTTPLIB "Use the bundled version of cpp-httplib." ON)
70 option(USE_BUNDLED_BLURHASH "Use the bundled version of blurhash." ON)
71
72 include(CMakeDependentOption)
73 set(VOIP_DEFAULT ON)
74 if(APPLE OR WIN32 OR HAIKU)
75 set(VOIP_DEFAULT OFF)
76 endif()
77 option(VOIP "Whether to enable voip support. Disable this, if you don't have gstreamer." ${VOIP_DEFAULT})
78 set(X11_DEFAULT)
79 if(WIN32 OR APPLE OR HAIKU)
80 set(X11_DEFAULT OFF)
81 endif()
82 option(X11 "Whether to enable X11 specific features (screenshare, window roles)." ${X11_DEFAULT})
83 cmake_dependent_option(SCREENSHARE_XDP "Whether to enable screenshare support using xdg-desktop-portal." ON "VOIP" OFF)
84
85 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
86
87 if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
88 message("Adding FetchContent_MakeAvailable")
89 # from cmakes sources
90 macro(FetchContent_MakeAvailable)
91 foreach(contentName IN ITEMS ${ARGV})
92 string(TOLOWER ${contentName} contentNameLower)
93 FetchContent_GetProperties(${contentName})
94 if(NOT ${contentNameLower}_POPULATED)
95 FetchContent_Populate(${contentName})
96
97 # Only try to call add_subdirectory() if the populated content
98 # can be treated that way. Protecting the call with the check
99 # allows this function to be used for projects that just want
100 # to ensure the content exists, such as to provide content at
101 # a known location.
102 if(EXISTS ${${contentNameLower}_SOURCE_DIR}/CMakeLists.txt)
103 add_subdirectory(${${contentNameLower}_SOURCE_DIR}
104 ${${contentNameLower}_BINARY_DIR})
105 endif()
106 endif()
107 endforeach()
108 endmacro()
109 endif()
110
111 # Include Qt basic functions
112 include(QtCommon)
113
114 include(GNUInstallDirs)
115
116 set(CPACK_PACKAGE_VERSION_MAJOR "0")
117 set(CPACK_PACKAGE_VERSION_MINOR "12")
118 set(CPACK_PACKAGE_VERSION_PATCH "1")
119 set(PROJECT_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR})
120 set(PROJECT_VERSION_MINOR ${CPACK_PACKAGE_VERSION_MINOR})
121 set(PROJECT_VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH})
122
123 # Set PROJECT_VERSION_PATCH & PROJECT_VERSION_TWEAK to 0 if not present
124 # Needed by add_project_meta.
125 fix_project_version()
126
127 # Set additional project information
128 set(COMPANY "Nheko")
129 set(COPYRIGHT "Copyright (c) 2024 Nheko Contributors")
130 set(IDENTIFIER "im.nheko.Nheko")
131
132 add_project_meta(META_FILES_TO_INCLUDE)
133
134 if(NOT MSVC AND NOT APPLE)
135 set(THREADS_PREFER_PTHREAD_FLAG ON)
136 find_package(Threads REQUIRED)
137 endif()
138
139 if(BUILD_DOCS)
140 find_package(Doxygen)
141
142 if(DOXYGEN_FOUND)
143 set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Doxyfile.in)
144 set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
145
146 configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT})
147
148 add_custom_target(docs ALL
149 COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
150 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
151 COMMENT "Generating API documentation with Doxygen"
152 VERBATIM )
153 else(DOXYGEN_FOUND)
154 message("Doxygen need to be installed to generate the doxygen documentation")
155 endif(DOXYGEN_FOUND)
156 endif()
157
158 #
159 ## coeurl
160 #
161 ## Need to repeat all libevent deps?!?
162 if(USE_BUNDLED_LIBEVENT)
163 hunter_add_package_safe(Libevent)
164 find_package(Libevent CONFIG REQUIRED)
165 else()
166 find_package(PkgConfig REQUIRED)
167 pkg_check_modules(libevent_core REQUIRED IMPORTED_TARGET libevent_core)
168 if(WIN32)
169 pkg_check_modules(libevent_windows REQUIRED IMPORTED_TARGET libevent_windows)
170 else()
171 pkg_check_modules(libevent_pthreads REQUIRED IMPORTED_TARGET libevent_pthreads)
172 endif()
173 endif()
174
175 # curl
176 if(USE_BUNDLED_LIBCURL)
177 hunter_add_package_safe(CURL)
178 find_package(CURL CONFIG REQUIRED)
179 else()
180 find_package(PkgConfig REQUIRED)
181 pkg_check_modules(libcurl REQUIRED IMPORTED_TARGET libcurl)
182 endif()
183
184 # fmt
185 if(USE_BUNDLED_FMT)
186 hunter_add_package_safe(fmt)
187 endif()
188 find_package(fmt 8.0.0 CONFIG REQUIRED)
189
190 # spdlog
191 if(USE_BUNDLED_SPDLOG)
192 hunter_add_package_safe(spdlog)
193 endif()
194 find_package(spdlog 1.0.0 CONFIG REQUIRED)
195
196 if(USE_BUNDLED_COEURL)
197 include(FetchContent)
198 FetchContent_Declare(
199 coeurl
200 GIT_REPOSITORY https://nheko.im/Nheko-Reborn/coeurl.git
201 GIT_TAG 831e2ee8e9cf08ea1ee9736cde8370f9d0312abc
202 )
203 FetchContent_MakeAvailable(coeurl)
204 set(COEURL_TARGET_NAME coeurl::coeurl)
205 else()
206 find_package(PkgConfig)
207 pkg_check_modules(coeurl IMPORTED_TARGET coeurl>=0.3.0)
208 if(TARGET PkgConfig::coeurl)
209 set(COEURL_TARGET_NAME PkgConfig::coeurl)
210 endif()
211 endif()
212
213 if(NOT TARGET PkgConfig::coeurl)
214 find_package(coeurl 0.2.1 CONFIG)
215 if(TARGET coeurl::coeurl)
216 set(COEURL_TARGET_NAME coeurl::coeurl)
217 endif()
218 endif()
219
220 if(NOT COEURL_TARGET_NAME)
221 message(ERROR "Couldn't find coeurl")
222 endif()
223
224 if(USE_BUNDLED_RE2)
225 hunter_add_package(re2)
226 find_package(re2 CONFIG REQUIRED)
227 else()
228 find_package(PkgConfig REQUIRED)
229 pkg_check_modules(re2 REQUIRED IMPORTED_TARGET re2)
230 endif()
231
232 #
233 # LMDB
234 #
235 #include(LMDB)
236 if(USE_BUNDLED_LMDB)
237 hunter_add_package_safe(lmdb)
238 find_package(liblmdb CONFIG REQUIRED)
239
240 target_include_directories(liblmdb::lmdb INTERFACE
241 "${HUNTER_INSTALL_PREFIX}/include/lmdb")
242 else()
243 find_package(LMDB REQUIRED)
244 endif()
245
246 #
247 # Discover Qt dependencies.
248 #
249 find_package(Qt6 6.5 COMPONENTS Core Widgets Gui LinguistTools Svg Multimedia Qml QuickControls2 REQUIRED)
250 find_package(Qt6DBus)
251
252 if(USE_BUNDLED_QTKEYCHAIN)
253 include(FetchContent)
254 set(BUILD_WITH_QT6 ON)
255 FetchContent_Declare(
256 qt6keychain
257 GIT_REPOSITORY https://github.com/frankosterfeld/qtkeychain.git
258 GIT_TAG v0.14.0
259 )
260 set(BUILD_TEST_APPLICATION OFF CACHE INTERNAL "")
261 FetchContent_MakeAvailable(qt6keychain)
262 else()
263 find_package(Qt6Keychain REQUIRED)
264 endif()
265
266 if(USE_BUNDLED_KDSINGLEAPPLICATION)
267 include(FetchContent)
268 set(KDSingleApplication_QT6 ON CACHE BOOL INTERNAL)
269 set(KDSingleApplication_EXAMPLES OFF CACHE BOOL INTERNAL)
270 FetchContent_Declare(
271 kdsingleapplication
272 GIT_REPOSITORY https://github.com/KDAB/KDSingleApplication.git
273 GIT_TAG v1.0.0
274 )
275 FetchContent_MakeAvailable(kdsingleapplication)
276 else()
277 find_package(KDSingleApplication-qt6 REQUIRED)
278 endif()
279
280 if(Qt6Widgets_FOUND)
281 if(Qt6Widgets_VERSION VERSION_LESS 6.5.0)
282 message(STATUS "Qt version ${Qt6Widgets_VERSION}")
283 message(WARNING "Minimum supported Qt6 version is 6.5!")
284 endif()
285 endif(Qt6Widgets_FOUND)
286
287 set(CMAKE_INCLUDE_CURRENT_DIR ON)
288 if(NOT MSVC)
289 set(
290 CMAKE_CXX_FLAGS
291 "${CMAKE_CXX_FLAGS} \
292 -Wall \
293 -Wextra \
294 -pedantic \
295 -fsized-deallocation \
296 -fdiagnostics-color=always \
297 -Wunreachable-code \
298 -Wno-attributes"
299 )
300 if(NOT CMAKE_COMPILER_IS_GNUCXX)
301 # -Wshadow is buggy and broken in GCC, so do not enable it.
302 # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79328
303 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
304 endif()
305 endif()
306
307 if(MSVC)
308 set(
309 CMAKE_CXX_FLAGS
310 "${CMAKE_CXX_FLAGS} /bigobj"
311 )
312 endif()
313
314 if(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES))
315 set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
316 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
317 FORCE)
318 message("Setting build type to '${CMAKE_BUILD_TYPE}'")
319 else(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES))
320 message("Build type set to '${CMAKE_BUILD_TYPE}'")
321 endif(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES))
322
323 set(SPDLOG_DEBUG_ON false)
324
325 # Windows doesn't handle CMAKE_BUILD_TYPE.
326 if(NOT WIN32)
327 if(CMAKE_BUILD_TYPE STREQUAL "Debug")
328 set(SPDLOG_DEBUG_ON true)
329 else()
330 set(SPDLOG_DEBUG_ON false)
331 endif()
332 endif()
333
334 find_program(GIT git)
335 if(GIT)
336 execute_process(
337 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
338 COMMAND ${GIT} rev-parse --short HEAD
339 OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE
340 )
341 if(GIT_OUT)
342 set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}-${GIT_OUT}")
343 else()
344 set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}")
345 endif()
346 endif(GIT)
347
348 set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
349 set(PROJECT_VERSION ${CPACK_PACKAGE_VERSION})
350
351 message(STATUS "Version: ${PROJECT_VERSION}")
352
353 cmake_host_system_information(RESULT BUILD_HOST QUERY HOSTNAME)
354
355 include(CheckSymbolExists)
356 check_symbol_exists(backtrace_symbols_fd "execinfo.h" HAVE_BACKTRACE_SYMBOLS_FD)
357
358 configure_file(cmake/nheko.h config/nheko.h)
359
360 #
361 # Declare source and header files.
362 #
363 set(SRC_FILES
364 # Emoji
365 src/emoji/Provider.cpp
366 src/emoji/Provider.h
367 src/emoji/Emoji.cpp
368 src/emoji/Emoji.h
369
370 # Timeline
371 src/timeline/CommunitiesModel.cpp
372 src/timeline/CommunitiesModel.h
373 src/timeline/DelegateChooser.cpp
374 src/timeline/DelegateChooser.h
375 src/timeline/EventStore.cpp
376 src/timeline/EventStore.h
377 src/timeline/EventDelegateChooser.cpp
378 src/timeline/EventDelegateChooser.h
379 src/timeline/InputBar.cpp
380 src/timeline/InputBar.h
381 src/timeline/Permissions.cpp
382 src/timeline/Permissions.h
383 src/timeline/PresenceEmitter.cpp
384 src/timeline/PresenceEmitter.h
385 src/timeline/Reaction.cpp
386 src/timeline/Reaction.h
387 src/timeline/RoomlistModel.cpp
388 src/timeline/RoomlistModel.h
389 src/timeline/TimelineFilter.cpp
390 src/timeline/TimelineFilter.h
391 src/timeline/TimelineModel.cpp
392 src/timeline/TimelineModel.h
393 src/timeline/TimelineViewManager.cpp
394 src/timeline/TimelineViewManager.h
395
396 # UI components
397 src/ui/HiddenEvents.cpp
398 src/ui/HiddenEvents.h
399 src/ui/EventExpiry.cpp
400 src/ui/EventExpiry.h
401 src/ui/MxcAnimatedImage.cpp
402 src/ui/MxcAnimatedImage.h
403 src/ui/MxcMediaProxy.cpp
404 src/ui/MxcMediaProxy.h
405 src/ui/NhekoCursorShape.cpp
406 src/ui/NhekoCursorShape.h
407 src/ui/NhekoDropArea.cpp
408 src/ui/NhekoDropArea.h
409 src/ui/NhekoGlobalObject.cpp
410 src/ui/NhekoGlobalObject.h
411 src/ui/NhekoMenuVisibilityFilter.h
412 src/ui/NhekoMenuVisibilityFilter.cpp
413 src/ui/RoomSettings.cpp
414 src/ui/RoomSettings.h
415 src/ui/RoomSummary.cpp
416 src/ui/RoomSummary.h
417 src/ui/Theme.cpp
418 src/ui/Theme.h
419 src/ui/UIA.cpp
420 src/ui/UIA.h
421 src/ui/UserProfile.cpp
422 src/ui/UserProfile.h
423
424 src/voip/CallDevices.cpp
425 src/voip/CallDevices.h
426 src/voip/CallManager.cpp
427 src/voip/CallManager.h
428 src/voip/ScreenCastPortal.cpp
429 src/voip/ScreenCastPortal.h
430 src/voip/WebRTCSession.h
431 src/voip/WebRTCSession.cpp
432 src/voip/WebRTCSession.h
433
434 src/encryption/DeviceVerificationFlow.cpp
435 src/encryption/DeviceVerificationFlow.h
436 src/encryption/Olm.cpp
437 src/encryption/Olm.h
438 src/encryption/SelfVerificationStatus.cpp
439 src/encryption/SelfVerificationStatus.h
440 src/encryption/VerificationManager.cpp
441 src/encryption/VerificationManager.h
442
443 # Generic notification stuff
444 src/notifications/Manager.cpp
445 src/notifications/Manager.h
446
447 src/dock/Dock.cpp
448 src/dock/Dock.h
449
450 src/AliasEditModel.cpp
451 src/AliasEditModel.h
452 src/AvatarProvider.cpp
453 src/AvatarProvider.h
454 src/BlurhashProvider.cpp
455 src/BlurhashProvider.h
456 src/Cache.cpp
457 src/Cache.h
458 src/CacheCryptoStructs.cpp
459 src/CacheCryptoStructs.h
460 src/CacheStructs.h
461 src/Cache_p.h
462 src/ChatPage.cpp
463 src/ChatPage.h
464 src/Clipboard.cpp
465 src/Clipboard.h
466 src/ColorImageProvider.cpp
467 src/ColorImageProvider.h
468 src/CombinedImagePackModel.cpp
469 src/CombinedImagePackModel.h
470 src/GridImagePackModel.cpp
471 src/GridImagePackModel.h
472 src/CommandCompleter.cpp
473 src/CommandCompleter.h
474 src/CompletionModelRoles.h
475 src/CompletionProxyModel.cpp
476 src/CompletionProxyModel.h
477 src/Config.h
478 src/EventAccessors.cpp
479 src/EventAccessors.h
480 src/FallbackAuth.cpp
481 src/FallbackAuth.h
482 src/ImagePackListModel.cpp
483 src/ImagePackListModel.h
484 src/InviteesModel.cpp
485 src/InviteesModel.h
486 src/JdenticonProvider.cpp
487 src/JdenticonProvider.h
488 src/Logging.cpp
489 src/Logging.h
490 src/LoginPage.cpp
491 src/LoginPage.h
492 src/MainWindow.cpp
493 src/MainWindow.h
494 src/MatrixClient.cpp
495 src/MatrixClient.h
496 src/MemberList.cpp
497 src/MemberList.h
498 src/MxcImageProvider.cpp
499 src/MxcImageProvider.h
500 src/PowerlevelsEditModels.cpp
501 src/PowerlevelsEditModels.h
502 src/ReadReceiptsModel.cpp
503 src/ReadReceiptsModel.h
504 src/ReCaptcha.cpp
505 src/ReCaptcha.h
506 src/RegisterPage.cpp
507 src/RegisterPage.h
508 src/RoomDirectoryModel.cpp
509 src/RoomDirectoryModel.h
510 src/RoomsModel.cpp
511 src/RoomsModel.h
512 src/SSOHandler.cpp
513 src/SSOHandler.h
514 src/SingleImagePackModel.cpp
515 src/SingleImagePackModel.h
516 src/TrayIcon.cpp
517 src/TrayIcon.h
518 src/UserSettingsPage.cpp
519 src/UserSettingsPage.h
520 src/UsersModel.cpp
521 src/UsersModel.h
522 src/Utils.cpp
523 src/Utils.h
524
525 includes/jdenticoninterface.h
526
527 src/main.cpp
528 )
529
530 include(FeatureSummary)
531
532 if(USE_BUNDLED_OPENSSL)
533 hunter_add_package_safe(OpenSSL)
534 endif()
535 find_package(OpenSSL 1.1.0 REQUIRED)
536 if(USE_BUNDLED_OLM)
537 include(FetchContent)
538 FetchContent_Declare(
539 Olm
540 GIT_REPOSITORY https://gitlab.matrix.org/matrix-org/olm.git
541 GIT_TAG 3.2.16
542 PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/third_party/olm-patches/0001-fix-list-const-ptr.patch
543 UPDATE_DISCONNECTED 1
544 )
545 set(OLM_TESTS OFF CACHE INTERNAL "")
546 FetchContent_MakeAvailable(Olm)
547 else()
548 find_package(Olm 3.2.7 REQUIRED)
549 set_package_properties(Olm PROPERTIES
550 DESCRIPTION "An implementation of the Double Ratchet cryptographic ratchet"
551 URL "https://git.matrix.org/git/olm/about/"
552 TYPE REQUIRED
553 )
554 endif()
555 if(USE_BUNDLED_SPDLOG)
556 hunter_add_package_safe(spdlog)
557 endif()
558 find_package(spdlog 1.0.0 CONFIG REQUIRED)
559
560 if(USE_BUNDLED_CMARK)
561 include(FetchContent)
562 FetchContent_Declare(
563 cmark
564 GIT_REPOSITORY https://github.com/commonmark/cmark.git
565 GIT_TAG 0.31.1
566 CMAKE_ARGS "BUILD_TESTING=OFF"
567 )
568 FetchContent_MakeAvailable(cmark)
569 if (NOT TARGET cmark::cmark)
570 add_library(cmark::cmark ALIAS cmark)
571 endif()
572 else()
573 find_package(cmark REQUIRED 0.29.0)
574 endif()
575
576 if(USE_BUNDLED_JSON)
577 hunter_add_package_safe(nlohmann_json)
578 endif()
579 find_package(nlohmann_json 3.2.0)
580 set_package_properties(nlohmann_json PROPERTIES
581 DESCRIPTION "JSON for Modern C++, a C++11 header-only JSON class"
582 URL "https://nlohmann.github.io/json/"
583 TYPE REQUIRED
584 )
585
586 if(USE_BUNDLED_LMDBXX)
587 include(FetchContent)
588 FetchContent_Declare(
589 lmdbxx
590 URL "https://raw.githubusercontent.com/hoytech/lmdbxx/1.0.0/lmdb++.h"
591 DOWNLOAD_NO_EXTRACT TRUE
592 CONFIGURE_COMMAND ""
593 BUILD_COMMAND ""
594 )
595 FetchContent_Populate(lmdbxx)
596 add_library(lmdbxx INTERFACE)
597 target_include_directories(lmdbxx INTERFACE ${lmdbxx_SOURCE_DIR})
598 add_library(lmdbxx::lmdbxx ALIAS lmdbxx)
599 else()
600 if(NOT LMDBXX_INCLUDE_DIR)
601 find_path(LMDBXX_INCLUDE_DIR
602 NAMES lmdb++.h
603 PATHS /usr/include
604 /usr/local/include
605 $ENV{LIB_DIR}/include
606 $ENV{LIB_DIR}/include/lmdbxx)
607 endif()
608 add_library(lmdbxx INTERFACE)
609 target_include_directories(lmdbxx INTERFACE ${LMDBXX_INCLUDE_DIR})
610 add_library(lmdbxx::lmdbxx ALIAS lmdbxx)
611 endif()
612
613 if(USE_BUNDLED_MTXCLIENT)
614 include(FetchContent)
615 FetchContent_Declare(
616 MatrixClient
617 GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
618 GIT_TAG v0.10.1
619 )
620 set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
621 set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
622 FetchContent_MakeAvailable(MatrixClient)
623 else()
624 find_package(MatrixClient 0.10.0 REQUIRED)
625 endif()
626
627 if(VOIP)
628 include(FindPkgConfig)
629 pkg_check_modules(GSTREAMER REQUIRED IMPORTED_TARGET gstreamer-sdp-1.0>=1.18 gstreamer-webrtc-1.0>=1.18 gstreamer-gl-1.0)
630 if (WIN32)
631 pkg_check_modules(GSTREAMER REQUIRED IMPORTED_TARGET gstreamer-d3d11-1.0)
632 endif()
633 endif()
634
635 if(X11 AND NOT WIN32 AND NOT APPLE AND NOT HAIKU)
636 pkg_check_modules(XCB REQUIRED IMPORTED_TARGET xcb xcb-ewmh)
637 endif()
638
639 feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
640
641 # this must be defined here to make the moc work properly
642 if(NOT APPLE AND NOT WIN32)
643 add_compile_definitions(NHEKO_DBUS_SYS)
644 endif()
645
646 #
647 # Bundle resources
648 #
649 qt_add_resources(QRC resources/res.qrc)
650
651 if(APPLE)
652 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation -framework Cocoa -framework UserNotifications")
653 set(SRC_FILES ${SRC_FILES} src/notifications/NotificationManagerProxy.h src/notifications/MacNotificationDelegate.h src/notifications/MacNotificationDelegate.mm src/notifications/ManagerMac.mm src/notifications/ManagerMac.cpp)
654 if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
655 set_source_files_properties( src/notifications/NotificationManagerProxy.h src/notifications/MacNotificationDelegate.h src/notifications/MacNotificationDelegate.mm src/notifications/ManagerMac.mm PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
656 endif()
657 elseif(WIN32)
658 file(DOWNLOAD
659 "https://raw.githubusercontent.com/mohabouje/WinToast/v1.3.0/src/wintoastlib.cpp"
660 ${PROJECT_SOURCE_DIR}/src/wintoastlib.cpp
661 EXPECTED_HASH SHA256=1ddf8ee2604e1757d383a2f60d4d597c4f5d9496369e6a22586cedf4af77ca8f)
662
663 file(DOWNLOAD
664 "https://raw.githubusercontent.com/mohabouje/WinToast/v1.3.0/include/wintoastlib.h"
665 ${PROJECT_SOURCE_DIR}/src/wintoastlib.h
666 EXPECTED_HASH SHA256=08cb30d28db9c851d3d4259ae6108ce7dafa966957df6735a06cd55e0716fded)
667
668 set(SRC_FILES ${SRC_FILES} src/notifications/ManagerWin.cpp src/wintoastlib.cpp src/wintoastlib.h)
669 else()
670 set(SRC_FILES ${SRC_FILES}
671 src/dbus/NhekoDBusApi.h
672 src/dbus/NhekoDBusBackend.h
673 src/dbus/NhekoDBusApi.cpp
674 src/dbus/NhekoDBusBackend.cpp
675 src/notifications/ManagerLinux.cpp
676 )
677 endif()
678
679 set(NHEKO_DEPS
680 ${SRC_FILES}
681 ${QRC}
682 ${META_FILES_TO_INCLUDE})
683
684 if(ASAN)
685 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined")
686 endif()
687
688 if(WIN32)
689 qt_add_executable(nheko WIN32 ${OS_BUNDLE} ${NHEKO_DEPS})
690 target_compile_definitions(nheko PRIVATE _WIN32_WINNT=0x0601 NOMINMAX WIN32_LEAN_AND_MEAN STRICT)
691 else()
692 qt_add_executable(nheko ${OS_BUNDLE} ${NHEKO_DEPS})
693
694 if(APPLE)
695 set_target_properties(nheko PROPERTIES MACOSX_BUNDLE_INFO_PLIST
696 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in")
697 endif()
698
699 if(HAVE_BACKTRACE_SYMBOLS_FD AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
700 set_target_properties(nheko PROPERTIES ENABLE_EXPORTS ON)
701 endif()
702 endif()
703
704 set_target_properties(nheko
705 PROPERTIES
706 CMAKE_SKIP_INSTALL_RPATH TRUE
707 AUTOMOC ON)
708
709 #
710 # Add qml files
711 #
712
713 set(QML_SOURCES
714 resources/qml/Root.qml
715 resources/qml/ChatPage.qml
716 resources/qml/CommunitiesList.qml
717 resources/qml/RoomList.qml
718 resources/qml/Avatar.qml
719 resources/qml/Completer.qml
720 resources/qml/EncryptionIndicator.qml
721 resources/qml/ImageButton.qml
722 resources/qml/ElidedLabel.qml
723 resources/qml/MatrixText.qml
724 resources/qml/MatrixTextField.qml
725 resources/qml/ToggleButton.qml
726 resources/qml/UploadBox.qml
727 resources/qml/MessageInput.qml
728 resources/qml/MessageView.qml
729 resources/qml/PrivacyScreen.qml
730 resources/qml/Reactions.qml
731 resources/qml/ReplyPopup.qml
732 resources/qml/StatusIndicator.qml
733 resources/qml/TimelineEvent.qml
734 resources/qml/TimelineSectionHeader.qml
735 resources/qml/TimelineDefaultMessageStyle.qml
736 resources/qml/TimelineBubbleMessageStyle.qml
737 resources/qml/TimelineMetadata.qml
738 resources/qml/TimelineView.qml
739 resources/qml/TopBar.qml
740 resources/qml/QuickSwitcher.qml
741 resources/qml/ForwardCompleter.qml
742 resources/qml/SelfVerificationCheck.qml
743 resources/qml/TypingIndicator.qml
744 resources/qml/MessageInputWarning.qml
745 resources/qml/components/AdaptiveLayout.qml
746 resources/qml/components/AdaptiveLayoutElement.qml
747 resources/qml/components/AvatarListTile.qml
748 resources/qml/components/FlatButton.qml
749 resources/qml/components/MainWindowDialog.qml
750 resources/qml/components/NhekoTabButton.qml
751 resources/qml/components/NotificationBubble.qml
752 resources/qml/components/PowerlevelIndicator.qml
753 resources/qml/components/ReorderableListview.qml
754 resources/qml/components/SpaceMenu.qml
755 resources/qml/components/SpaceMenuLevel.qml
756 resources/qml/components/TextButton.qml
757 resources/qml/components/UserListRow.qml
758 resources/qml/delegates/Encrypted.qml
759 resources/qml/delegates/FileMessage.qml
760 resources/qml/delegates/ImageMessage.qml
761 resources/qml/delegates/NoticeMessage.qml
762 resources/qml/delegates/Pill.qml
763 resources/qml/delegates/Placeholder.qml
764 resources/qml/delegates/PlayableMediaMessage.qml
765 resources/qml/delegates/Redacted.qml
766 resources/qml/delegates/Reply.qml
767 resources/qml/delegates/TextMessage.qml
768 resources/qml/device-verification/DeviceVerification.qml
769 resources/qml/device-verification/DigitVerification.qml
770 resources/qml/device-verification/EmojiVerification.qml
771 resources/qml/device-verification/Failed.qml
772 resources/qml/device-verification/NewVerificationRequest.qml
773 resources/qml/device-verification/Success.qml
774 resources/qml/device-verification/Waiting.qml
775 resources/qml/dialogs/AliasEditor.qml
776 resources/qml/dialogs/ConfirmJoinRoomDialog.qml
777 resources/qml/dialogs/CreateDirect.qml
778 resources/qml/dialogs/CreateRoom.qml
779 resources/qml/dialogs/FallbackAuthDialog.qml
780 resources/qml/dialogs/HiddenEventsDialog.qml
781 resources/qml/dialogs/EventExpirationDialog.qml
782 resources/qml/dialogs/ImageOverlay.qml
783 resources/qml/dialogs/ImagePackEditorDialog.qml
784 resources/qml/dialogs/ImagePackDeleteDialog.qml
785 resources/qml/dialogs/ImagePackSettingsDialog.qml
786 resources/qml/dialogs/InputDialog.qml
787 resources/qml/dialogs/InviteDialog.qml
788 resources/qml/dialogs/JoinRoomDialog.qml
789 resources/qml/dialogs/LeaveRoomDialog.qml
790 resources/qml/dialogs/LogoutDialog.qml
791 resources/qml/dialogs/PhoneNumberInputDialog.qml
792 resources/qml/dialogs/PowerLevelEditor.qml
793 resources/qml/dialogs/PowerLevelSpacesApplyDialog.qml
794 resources/qml/dialogs/RawMessageDialog.qml
795 resources/qml/dialogs/ReadReceipts.qml
796 resources/qml/dialogs/ReCaptchaDialog.qml
797 resources/qml/dialogs/ReportMessage.qml
798 resources/qml/dialogs/RoomDirectory.qml
799 resources/qml/dialogs/RoomMembers.qml
800 resources/qml/dialogs/AllowedRoomsSettingsDialog.qml
801 resources/qml/dialogs/RoomSettingsDialog.qml
802 resources/qml/dialogs/UserProfile.qml
803 resources/qml/dialogs/IgnoredUsers.qml
804 resources/qml/emoji/StickerPicker.qml
805 resources/qml/pages/LoginPage.qml
806 resources/qml/pages/RegisterPage.qml
807 resources/qml/pages/UserSettingsPage.qml
808 resources/qml/pages/WelcomePage.qml
809 resources/qml/ui/NhekoSlider.qml
810 resources/qml/ui/Ripple.qml
811 resources/qml/ui/Snackbar.qml
812 resources/qml/ui/Spinner.qml
813 resources/qml/ui/animations/BlinkAnimation.qml
814 resources/qml/ui/media/MediaControls.qml
815 resources/qml/voip/ActiveCallBar.qml
816 resources/qml/voip/CallDevices.qml
817 resources/qml/voip/CallInvite.qml
818 resources/qml/voip/CallInviteBar.qml
819 resources/qml/voip/DeviceError.qml
820 resources/qml/voip/PlaceCall.qml
821 resources/qml/voip/ScreenShare.qml
822 resources/qml/voip/VideoCall.qml
823 resources/qml/voip/VideoCallD3D11.qml
824 resources/qml/delegates/EncryptionEnabled.qml
825 resources/qml/ui/TimelineEffects.qml
826 )
827 qt_add_qml_module(nheko
828 URI im.nheko
829 NO_RESOURCE_TARGET_PATH
830 RESOURCE_PREFIX "/"
831 VERSION 1.1
832 DEPENDENCIES QtQuick QtQml.Models
833 QML_FILES
834 ${QML_SOURCES}
835 SOURCES
836 src/UserDirectoryModel.cpp
837 src/UserDirectoryModel.h
838 )
839 #qt_target_qml_sources(nheko
840 # #PREFIX "/"
841 #)
842
843 #set_target_properties(nheko PROPERTIES
844 # QT_QMLCACHEGEN_ARGUMENTS "--verbose"
845 #)
846
847 #
848 # Bundle translations
849 #
850 file(GLOB LANG_TS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/*.ts")
851 qt_add_translations(nheko RESOURCE_PREFIX "/translations" TS_FILES
852 ${LANG_TS_SRC} SOURCES ${QML_SOURCES} ${SRC_FILES})
853
854 if(WIN32)
855 target_compile_definitions(nheko PRIVATE WIN32_LEAN_AND_MEAN)
856 target_link_libraries(nheko PRIVATE Qt6::DBus)
857 if(MSVC)
858 target_compile_options(nheko PUBLIC "/Zc:__cplusplus")
859 endif()
860 else()
861 target_link_libraries(nheko PRIVATE Qt6::DBus)
862 if(FLATPAK)
863 target_compile_definitions(nheko PRIVATE NHEKO_FLATPAK)
864 endif()
865 endif()
866
867 target_include_directories(nheko PRIVATE src includes src/timeline/ src/ui/ src/encryption/ src/voip/)
868
869 if(USE_BUNDLED_CPPHTTPLIB)
870 target_include_directories(nheko PRIVATE third_party/cpp-httplib-0.5.12)
871 target_sources(nheko PRIVATE third_party/cpp-httplib-0.5.12/httplib.h)
872 else()
873 find_package(httplib REQUIRED)
874 target_link_libraries(nheko PRIVATE httplib::httplib)
875 endif()
876
877 if(USE_BUNDLED_BLURHASH)
878 target_include_directories(nheko PRIVATE third_party/blurhash)
879 set(BLURHASH_SRC_FILES
880 third_party/blurhash/blurhash.cpp
881 third_party/blurhash/blurhash.hpp
882 )
883 target_sources(nheko PRIVATE ${BLURHASH_SRC_FILES})
884 else()
885 find_package(PkgConfig REQUIRED)
886 pkg_check_modules(blurhash REQUIRED IMPORTED_TARGET blurhash)
887 target_link_libraries(nheko PRIVATE PkgConfig::blurhash)
888 endif()
889
890 # Fixup bundled keychain include dirs
891 if(USE_BUNDLED_QTKEYCHAIN)
892 target_include_directories(nheko PRIVATE ${qt6keychain_SOURCE_DIR} ${qt6keychain_BINARY_DIR})
893 endif()
894 if(USE_BUNDLED_KDSINGLEAPPLICATION)
895 target_include_directories(nheko PRIVATE ${kdsingleapplication_SOURCE_DIR} ${kdsingleapplication_BINARY_DIR})
896 endif()
897
898 if(NOT JSON_ImplicitConversions)
899 set_target_properties(nlohmann_json::nlohmann_json PROPERTIES
900 INTERFACE_COMPILE_DEFINITIONS "JSON_USE_IMPLICIT_CONVERSIONS=\$<BOOL:OFF>;JSON_DIAGNOSTICS=\$<BOOL:OFF>"
901 )
902 target_compile_definitions(nheko PUBLIC JSON_USE_IMPLICIT_CONVERSIONS=0)
903 endif()
904
905 target_link_libraries(nheko PRIVATE
906 ${COEURL_TARGET_NAME}
907 MatrixClient::MatrixClient
908 cmark::cmark
909 fmt::fmt
910 spdlog::spdlog
911 Qt::Widgets
912 Qt::Svg
913 Qt::Gui
914 Qt::Multimedia
915 Qt::Qml
916 Qt::QmlPrivate
917 Qt::QuickControls2
918 qt6keychain
919 KDAB::kdsingleapplication
920 nlohmann_json::nlohmann_json
921 lmdbxx::lmdbxx
922 liblmdb::lmdb)
923
924 if(UNIX)
925 # for wayland activation tokens
926 target_link_libraries(nheko PRIVATE Qt::GuiPrivate)
927 endif()
928
929 if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
930 target_precompile_headers(nheko
931 PRIVATE
932 <string>
933 <algorithm>
934 )
935 endif()
936
937 if(TARGET PkgConfig::GSTREAMER)
938 target_link_libraries(nheko PRIVATE PkgConfig::GSTREAMER)
939 target_compile_definitions(nheko PRIVATE GSTREAMER_AVAILABLE)
940 endif()
941 if(TARGET PkgConfig::XCB)
942 target_link_libraries(nheko PRIVATE PkgConfig::XCB)
943 target_compile_definitions(nheko PRIVATE XCB_AVAILABLE)
944 endif()
945
946 if(MSVC)
947 target_link_libraries(nheko PRIVATE ntdll)
948 endif()
949
950 if(HAIKU)
951 target_link_libraries(nheko PRIVATE network)
952 endif()
953
954 if(QML_DEBUGGING)
955 target_compile_definitions(nheko PRIVATE QML_DEBUGGING)
956 endif()
957
958 if(NOT MSVC AND NOT HAIKU)
959 if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR CI_BUILD)
960 target_compile_options(nheko PRIVATE "-Werror")
961 endif()
962 endif()
963 #if(NOT MSVC)
964 # target_link_options(nheko PRIVATE "LINKER:,--gc-sections")
965 #endif()
966
967 if(MAN)
968 add_subdirectory(man)
969 endif()
970
971 # potential workaround for macdeployqt issues
972 if(APPLE)
973 install(TARGETS nheko
974 BUNDLE DESTINATION .
975 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
976 )
977 qt_generate_deploy_qml_app_script(
978 TARGET nheko
979 OUTPUT_SCRIPT deploy_script
980 NO_UNSUPPORTED_PLATFORM_ERROR
981 )
982 install(SCRIPT ${deploy_script})
983 endif()
984
985 if(UNIX AND NOT APPLE)
986 if(FLATPAK)
987 set(APPID "im.nheko.Nheko")
988 set_target_properties(nheko PROPERTIES OUTPUT_NAME "${APPID}")
989 else()
990 set(APPID "nheko")
991 endif()
992
993 install(TARGETS nheko RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
994 install(FILES "resources/nheko-16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "${APPID}.png")
995 install(FILES "resources/nheko-32.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps" RENAME "${APPID}.png")
996 install(FILES "resources/nheko-48.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" RENAME "${APPID}.png")
997 install(FILES "resources/nheko-64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/64x64/apps" RENAME "${APPID}.png")
998 install(FILES "resources/nheko-128.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps" RENAME "${APPID}.png")
999 install(FILES "resources/nheko-256.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps" RENAME "${APPID}.png")
1000 install(FILES "resources/nheko-512.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/512x512/apps" RENAME "${APPID}.png")
1001 install(FILES "resources/nheko.svg" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps" RENAME "${APPID}.svg")
1002 install(FILES "resources/_nheko" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/zsh/site-functions")
1003
1004 configure_file("resources/nheko.desktop.in" "resources/nheko.desktop" @ONLY)
1005 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/resources/nheko.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" RENAME "${APPID}.desktop")
1006 configure_file("resources/nheko.appdata.xml.in" "resources/nheko.appdata.xml" @ONLY)
1007 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/resources/nheko.appdata.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo" RENAME "${APPID}.appdata.xml")
1008
1009 if(NOT TARGET uninstall)
1010 configure_file(
1011 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
1012 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
1013 IMMEDIATE @ONLY)
1014 add_custom_target(uninstall
1015 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
1016 endif()
1017 endif()
1018 # vim: tabstop=4 shiftwidth=4 expandtab