# SPDX-FileCopyrightText: 2026 Matvey Shcherbinin # SPDX-License-Identifier: BSD-2-Clause # Configured from the top level CMakeLists.txt, which owns project(), the ECM # lookup and the KDE includes. This file only describes the application. # KStatusNotifierItem's QMenu requires Qt Widgets and QApplication. find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Quick QuickControls2 QuickDialogs2 Multimedia Network Positioning Widgets) # OpenSSL provides certificate generation from the identity seed. find_package(OpenSSL REQUIRED) # Discover libsodium through pkg-config, and where there is no .pc file for # it - the Windows build's Craft prefix ships the library but not that file - # through its own library and header instead. A ready prefix layout can also # be handed over through SODIUM_DIR, which is how the CI's Windows job feeds # in the vendor's prebuilt release binaries. find_package(PkgConfig REQUIRED) pkg_check_modules(Sodium IMPORTED_TARGET libsodium>=1.0.18) if(NOT Sodium_FOUND) find_library(SODIUM_LIBRARY NAMES sodium libsodium HINTS ENV SODIUM_DIR PATH_SUFFIXES lib) find_path(SODIUM_INCLUDE_DIR NAMES sodium.h HINTS ENV SODIUM_DIR PATH_SUFFIXES include sodium) if(SODIUM_LIBRARY AND SODIUM_INCLUDE_DIR) add_library(PkgConfig::Sodium UNKNOWN IMPORTED) set_target_properties(PkgConfig::Sodium PROPERTIES IMPORTED_LOCATION ${SODIUM_LIBRARY} INTERFACE_INCLUDE_DIRECTORIES ${SODIUM_INCLUDE_DIR}) else() message(FATAL_ERROR "libsodium was not found by pkg-config or by its own name. " "Install it (package names: libsodium-devel, libsodium-dev) " "and configure again.") endif() endif() find_package(KF6 ${KF_MIN_VERSION} REQUIRED COMPONENTS BreezeIcons Config CoreAddons I18n IdleTime Kirigami Notifications StatusNotifierItem) # KWallet enables secret persistence across launches. find_package(KF6Wallet CONFIG) set_package_properties(KF6Wallet PROPERTIES TYPE RECOMMENDED PURPOSE "KWallet-backed secret store for the Ed25519/X25519 identity, the group passphrase and the Matrix tokens" ) if(KF6Wallet_FOUND) set(KOUTNET_HAVE_KWALLET TRUE) else() message(WARNING "KF6Wallet was not found - every read will miss, every write will be refused and secrets will not be persisted across launches.") endif() # The i18n() call in QML comes from the localized context object, which lives # in a target of its own rather than in KF6::I18n. if(NOT TARGET KF6::I18nQml) message(FATAL_ERROR "KF6::I18nQml is missing; QML strings cannot be translated without it") endif() # KColorSchemeManager::instance() and indexForSchemeId() require KF6 6.6. find_package(KF6ColorScheme 6.6 CONFIG) set_package_properties(KF6ColorScheme PROPERTIES TYPE REQUIRED PURPOSE "Dark, light and follow-the-system colour schemes" ) if(NOT KF6ColorScheme_FOUND) message(FATAL_ERROR "KF6ColorScheme 6.6 or newer was not found. It ships with KDE Frameworks 6 " "(package names: kcolorscheme, kf6-kcolorscheme, libkf6colorscheme-dev).") endif() # Check QML dependencies at configure time; ConvergentContextMenu requires 1.8. find_package(KF6KirigamiAddons 1.8.0 CONFIG) set_package_properties(KF6KirigamiAddons PROPERTIES TYPE REQUIRED PURPOSE "FormCard pages, list delegates, the image viewer and the convergent context menu" ) if(NOT KF6KirigamiAddons_FOUND) message(FATAL_ERROR "KF6KirigamiAddons 1.8.0 or newer was not found. Install kirigami-addons " "(package names: kirigami-addons, kf6-kirigami-addons, libkf6kirigamiaddons-dev) " "and configure again.") endif() # Room::postText() requires libQuotient 0.9. # Its cxx_std_23 interface requirement raises this target's C++ standard. find_package(QuotientQt6 0.9 CONFIG) set(KOUTNET_GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}) # TDLib is the Telegram client library and is required from 0.2 on: the # experimental Telegram transport ships, so a build without tdjson is not a # KOutNet build. On openSUSE Tumbleweed the package provides pkgconfig(tdjson). pkg_check_modules(TDLIB REQUIRED IMPORTED_TARGET tdjson) set(KOUTNET_HAVE_TDLIB TRUE) set_package_properties(QuotientQt6 PROPERTIES DESCRIPTION "Qt SDK for the Matrix protocol" URL "https://github.com/quotient-im/libQuotient" TYPE REQUIRED PURPOSE "K-Server mode: Matrix login, sync, room list and messages" ) if(NOT QuotientQt6_FOUND) message(FATAL_ERROR "libQuotient 0.9 or newer was not found. It is what K-Server mode is made of. " "Install it (package names: net-libs/libquotient on Gentoo, libquotient, " "libquotient-devel, libQuotient-dev) and configure again. It brings libolm, " "qtkeychain built for Qt 6 and Qt6::Sql with it; those are its dependencies " "rather than this project's.") endif() qt_standard_project_setup(REQUIRES 6.4) # Allow signal/slot as identifiers; use Q_EMIT, Q_SIGNALS and Q_SLOTS. add_compile_definitions(QT_NO_KEYWORDS) # Keep crypto logging separate for tests that compile CryptoManager directly. ecm_qt_declare_logging_category(KOUTNET_CRYPTO_LOGGING_SRCS HEADER koutnet_crypto_debug.h IDENTIFIER KOUTNET_LOG_CRYPTO CATEGORY_NAME koutnet.crypto DESCRIPTION "KOutNet identity keys, encryption and secret storage" EXPORT KOUTNET ) ecm_qt_declare_logging_category(KOUTNET_LOGGING_SRCS HEADER koutnet_network_debug.h IDENTIFIER KOUTNET_LOG_NETWORK CATEGORY_NAME koutnet.network DESCRIPTION "KOutNet peer discovery, transport and file transfer" EXPORT KOUTNET ) ecm_qt_declare_logging_category(KOUTNET_LOGGING_SRCS HEADER koutnet_chat_debug.h IDENTIFIER KOUTNET_LOG_CHAT CATEGORY_NAME koutnet.chat DESCRIPTION "KOutNet chat history, groups and reactions" EXPORT KOUTNET ) ecm_qt_declare_logging_category(KOUTNET_LOGGING_SRCS HEADER koutnet_audio_debug.h IDENTIFIER KOUTNET_LOG_AUDIO CATEGORY_NAME koutnet.audio DESCRIPTION "KOutNet audio devices, capture and playback" EXPORT KOUTNET ) ecm_qt_declare_logging_category(KOUTNET_LOGGING_SRCS HEADER koutnet_media_debug.h IDENTIFIER KOUTNET_LOG_MEDIA CATEGORY_NAME koutnet.media DESCRIPTION "KOutNet media previews: video posters and thumbnails" EXPORT KOUTNET ) ecm_qt_declare_logging_category(KOUTNET_LOGGING_SRCS HEADER koutnet_matrix_debug.h IDENTIFIER KOUTNET_LOG_MATRIX CATEGORY_NAME koutnet.matrix DESCRIPTION "KOutNet K-Server mode: the Matrix session, rooms and sync" EXPORT KOUTNET ) ecm_qt_declare_logging_category(KOUTNET_LOGGING_SRCS HEADER koutnet_app_debug.h IDENTIFIER KOUTNET_LOG_APP CATEGORY_NAME koutnet.app DESCRIPTION "KOutNet startup, settings and theming" EXPORT KOUTNET ) qt_add_executable(KOutNet main.cpp # Startup phases, kept out of main.cpp so each one can be read on its own. app/AppStartup.cpp app/AppStartup.h app/AppSettingsWire.cpp app/AppSettingsWire.h app/AppearanceSetup.cpp app/AppearanceSetup.h app/QmlSetup.cpp app/QmlSetup.h app/Session.cpp app/Session.h app/SettingsSync.h ${KOUTNET_LOGGING_SRCS} ${KOUTNET_CRYPTO_LOGGING_SRCS} core/audio/AudioEngine.cpp core/audio/AudioEngine.h core/audio/AudioMixer.cpp core/audio/AudioMixer.h core/audio/AudioDevices.cpp core/audio/AudioDevices.h core/security/CryptoManager.cpp core/security/CryptoManager.h core/security/SecretStore.cpp core/security/SecretStore.h core/constructor/AppSettings.cpp core/constructor/AppSettings.h core/chat/ChatAddress.cpp core/chat/ChatAddress.h core/backend/ChatBackend.h core/backend/ChatBackendRegistry.cpp core/backend/ChatBackendRegistry.h core/chat/MessageEntry.cpp core/chat/MessageEntry.h core/chat/HistoryManager.cpp core/chat/HistoryManager.h core/chat/UnreadManager.cpp core/chat/UnreadManager.h core/chat/ReactionStore.cpp core/chat/ReactionStore.h core/chat/GroupManager.cpp core/chat/GroupManager.h core/chat/ChatModel.cpp core/chat/ChatModel.h core/chat/ReversedChatModel.cpp core/chat/ReversedChatModel.h core/chat/ChatListModel.cpp core/chat/ChatListModel.h core/chat/ChatFolders.cpp core/chat/ChatFolders.h core/i18n/TranslationCatalog.cpp core/i18n/TranslationCatalog.h core/media/MediaCache.cpp core/media/MediaCache.h core/media/OutgoingFile.cpp core/media/OutgoingFile.h core/media/VideoPoster.cpp core/media/VideoPoster.h core/chat/RelativeTime.cpp core/chat/RelativeTime.h core/chat/TextHandler.cpp core/chat/TextHandler.h core/emoji/EmojiModel.cpp core/emoji/EmojiModel.h core/emoji/EmojiTones.cpp core/emoji/EmojiTones.h core/notify/NotificationManager.cpp core/notify/NotificationManager.h core/tray/TrayIcon.cpp core/tray/TrayIcon.h core/theme/AppPalette.cpp core/theme/AppPalette.h core/theme/ColorSchemeSelector.cpp core/theme/ColorSchemeSelector.h core/theme/FontSelector.cpp core/theme/FontSelector.h core/theme/IconThemeSelector.cpp core/theme/IconThemeSelector.h core/theme/StyleSelector.cpp core/theme/StyleSelector.h core/theme/ThemeLibrary.cpp core/theme/ThemeLibrary.h network/NetworkManager.cpp network/NetworkManager.h network/Protocol.h network/Protocol.cpp network/AddressUtils.h network/VoiceCallManager.cpp network/VoiceCallManager.h network/FileTransferHandler.cpp network/FileTransferHandler.h network/StunClient.cpp network/StunClient.h network/TlsChannel.cpp network/TlsChannel.h network/AvatarExchange.cpp network/AvatarExchange.h network/BannerExchange.cpp network/BannerExchange.h network/FileTransferSender.cpp network/FileTransferSender.h network/FrameRouter.cpp network/FrameRouter.h network/GroupKeyStore.cpp network/GroupKeyStore.h network/PresenceService.cpp network/PresenceService.h network/SessionTransport.cpp network/SessionTransport.h network/VoiceTransport.cpp network/VoiceTransport.h graphics/ImageCrop.cpp graphics/ImageCrop.h core/security/IdentityCertificate.cpp core/security/IdentityCertificate.h matrix/MatrixTranslate.cpp matrix/MatrixTranslate.h matrix/MatrixManager.cpp matrix/MatrixManager.h matrix/MatrixRoomBridge.cpp matrix/MatrixRoomBridge.h matrix/MatrixRoomBridge_p.h matrix/MatrixRoomCalls.cpp matrix/MatrixRoomMedia.cpp matrix/MatrixRoomMembers.cpp matrix/MatrixRoomModeration.cpp matrix/MatrixRoomPolls.cpp matrix/pollevent.cpp matrix/pollevent.h matrix/MatrixVerification.cpp matrix/MatrixVerification.h matrix/MatrixDirectory.cpp matrix/MatrixDirectory.h matrix/MatrixLoginUtils.cpp matrix/MatrixLoginUtils.h ) # The Telegram transport. TDLib is mandatory now, so TelegramBackend is always # the real thing; the experimental label is about feature coverage, not about # whether the library was linked. target_sources(KOutNet PRIVATE telegram/TelegramClient.cpp telegram/TelegramClient.h telegram/TelegramBackend.cpp ) if(KOUTNET_HAVE_TDLIB) target_compile_definitions(KOutNet PRIVATE KOUTNET_HAVE_TDLIB) target_link_libraries(KOutNet PRIVATE PkgConfig::TDLIB) endif() # Register the shared role labels as a singleton before qt_add_qml_module. set_source_files_properties(qml/matrix/RoomRoles.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE) set_source_files_properties(qml/FsUtils.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE) set_source_files_properties(qml/ThemePalette.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE) qt_add_qml_module(KOutNet URI koutnet.app VERSION 1.0 QML_FILES qml/FsUtils.qml qml/ThemePalette.qml qml/main_window/Main.qml qml/main_window/ChatListPage.qml qml/main_window/ChatFolderSection.qml qml/main_window/ChatListResizeHandle.qml qml/main_window/ChatSection.qml qml/main_window/ContactDelegate.qml qml/main_window/AccountRow.qml qml/main_window/ChatPage.qml qml/main_window/NewChatPage.qml qml/main_window/BrowsePage.qml qml/main_window/NewRoomDialog.qml qml/shell/ConnectionRail.qml qml/shell/ModeButton.qml qml/shell/AnimatedAvatar.qml qml/timeline/MessageTimeline.qml qml/timeline/MessageDelegate.qml qml/timeline/MessageBubble.qml qml/timeline/UserMenu.qml qml/timeline/MessageActions.qml qml/timeline/DateSeparator.qml qml/timeline/SystemMessage.qml qml/timeline/ReplyQuote.qml qml/timeline/ReactionFlow.qml qml/timeline/AttachmentBlock.qml qml/timeline/PollBlock.qml qml/timeline/DeliveryMark.qml qml/timeline/TypingIndicator.qml qml/composer/Composer.qml qml/composer/EmojiPicker.qml qml/composer/EmojiPopup.qml qml/composer/EmojiSidePanel.qml qml/composer/EmojiGrid.qml qml/composer/EmojiDelegate.qml qml/composer/EmojiTonesPicker.qml qml/composer/ReactionPicker.qml qml/peer/PeerCard.qml qml/peer/PeerInfoPage.qml qml/ThemedFormCard.qml qml/ThemedFormHeader.qml qml/settings/SettingsPage.qml qml/settings/AppearancePage.qml qml/settings/ProfileSettingsTab.qml qml/settings/LanSettingsTab.qml qml/settings/MatrixSettingsTab.qml qml/settings/TelegramSettingsTab.qml qml/settings/ThemeGallery.qml qml/settings/ThemeTile.qml qml/settings/CropSheet.qml qml/matrix/MatrixLoginPage.qml qml/matrix/TelegramLoginPage.qml qml/matrix/RoomRoles.qml qml/matrix/RoomInfoPage.qml qml/matrix/InvitationsPage.qml qml/matrix/RoomMemberCard.qml qml/matrix/DeviceVerificationDialog.qml qml/matrix/KeyBackupDialog.qml qml/tabs/NotesPage.qml qml/tabs/CallLogPage.qml qml/tabs/PlayerPage.qml qml/profile/ProfileHeader.qml qml/profile/ProfileBlock.qml qml/profile/AccountCard.qml qml/profile/other/OtherProfile.qml qml/call/OutgoingCallWindow.qml qml/call/IncomingCallDialog.qml qml/call/ActiveCallWindow.qml qml/file/IncomingFileDialog.qml qml/welcome/WizardWindow.qml qml/welcome/WizardPage.qml qml/welcome/WizardWelcomePage.qml qml/welcome/WizardNetworkPage.qml qml/welcome/WizardPowerfulPage.qml qml/welcome/WizardEnjoyPage.qml qml/welcome/mock/MockAppletBase.qml qml/welcome/mock/MockSystemTrayIcon.qml qml/welcome/mock/MockSystemTrayApplet.qml qml/welcome/mock/MockDigitalClockApplet.qml qml/welcome/mock/MockShowDesktopApplet.qml qml/welcome/mock/MockKickoffApplet.qml qml/welcome/mock/MockPanel.qml qml/welcome/mock/MockCard.qml RESOURCES assets/512-apps-io.github.bitzuka.koutnet.png assets/konoka-welcome-1st.png assets/konoka-welcome-last.png ) kconfig_add_kcfg_files(KOutNet GENERATE_MOC core/constructor/koutnetsettings.kcfgc) target_link_libraries(KOutNet PRIVATE Qt6::Core Qt6::Gui Qt6::Quick Qt6::QuickControls2 Qt6::QuickDialogs2 Qt6::Multimedia Qt6::Network Qt6::Positioning Qt6::Widgets PkgConfig::Sodium OpenSSL::Crypto KF6::BreezeIcons KF6::ColorScheme KF6::ConfigCore KF6::ConfigGui KF6::CoreAddons KF6::I18n KF6::I18nQml KF6::IdleTime KF6::Kirigami KF6::Notifications KF6::StatusNotifierItem QuotientQt6 ) if(KF6Wallet_FOUND) target_link_libraries(KOutNet PRIVATE KF6::Wallet) target_compile_definitions(KOutNet PRIVATE KOUTNET_HAVE_KWALLET) endif() if(WIN32) target_link_libraries(KOutNet PRIVATE iphlpapi) endif() install(TARGETS KOutNet ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) ki18n_install(${CMAKE_CURRENT_SOURCE_DIR}/../po) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../packaging/io.github.bitzuka.koutnet.desktop DESTINATION ${KDE_INSTALL_APPDIR}) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../packaging/io.github.bitzuka.koutnet.metainfo.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) # Named after the KAboutData component name rather than the application name, # because that is what NotificationManager sets on every KNotification it makes. install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../packaging/koutnet.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFYRCDIR}) ecm_install_icons( ICONS ${CMAKE_CURRENT_SOURCE_DIR}/assets/512-apps-io.github.bitzuka.koutnet.png DESTINATION ${KDE_INSTALL_ICONDIR} ) # The pictures a theme is, which is what ThemeLibrary lists. Guarded because the # folder is not in git - three hundred megabytes of wallpaper is nobody's # repository to carry - so whoever builds this keeps it beside the source, and an # installed build then finds the pictures at one of the paths ThemeLibrary looks # in rather than at a different set of names. A checkout without the folder has # nothing here to install, rather than a missing directory to fail on. if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/themes) install(DIRECTORY themes/ DESTINATION ${KDE_INSTALL_DATADIR}/koutnet/themes FILES_MATCHING PATTERN "*.jpg" PATTERN "*.jpeg" PATTERN "*.png" PATTERN "*.webp" PATTERN "*.bmp") endif() # Lets a bug reporter find the category names without reading the source. ecm_qt_install_logging_categories( EXPORT KOUTNET FILE koutnet.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR} ) set_target_properties(KOutNet PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) # The version header comes from ecm_setup_version at the top level, the logging # categories and the generated settings class from this directory's build tree. target_include_directories(KOutNet PRIVATE # matrix/ reaches core/ the way main.cpp does, by path from the source root. # Without this a quoted include from a subdirectory resolves against that # subdirectory and nowhere else. ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/core/theme ${CMAKE_CURRENT_SOURCE_DIR}/core/chat ${CMAKE_CURRENT_SOURCE_DIR}/core/emoji ${CMAKE_CURRENT_SOURCE_DIR}/core/i18n ${CMAKE_CURRENT_SOURCE_DIR}/core/media ${KOUTNET_GENERATED_INCLUDE_DIR} ${PROJECT_BINARY_DIR} ) option(BUILD_TESTING "Build the test suite" ON) if(BUILD_TESTING) find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Test) include(ECMAddTests) add_subdirectory(tests) endif()