2020-01-24 19:35:49 +03:00
cmake_minimum_required(VERSION 3.13)
2017-04-06 02:06:42 +03:00
2017-10-01 22:38:46 +03:00
option(APPVEYOR_BUILD "Build on appveyor" OFF)
2020-01-24 19:35:49 +03:00
option(CI_BUILD "Set when building in CI. Enables -Werror where possible" OFF)
2018-05-04 18:11:03 +03:00
option(ASAN "Compile with address sanitizers" OFF)
2019-12-15 01:48:02 +03:00
option(QML_DEBUGGING "Enable qml debugging" OFF)
2020-06-27 04:06:16 +03:00
option(COMPILE_QML "Compile Qml. It will make Nheko faster, but you will need to recompile it, when you update Qt." OFF)
2017-05-02 04:22:33 +03:00
2020-01-24 19:35:49 +03:00
set(
2020-01-25 02:58:22 +03:00
CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/toolchain.cmake"
CACHE
FILEPATH "Default toolchain"
)
2020-05-25 12:12:01 +03:00
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard")
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "Require C++ standard to be supported")
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "compile as PIC by default")
2020-01-24 19:35:49 +03:00
option(HUNTER_ENABLED "Enable Hunter package manager" OFF)
include("cmake/HunterGate.cmake")
HunterGate(
2021-06-30 13:45:41 +03:00
URL "https://github.com/cpp-pm/hunter/archive/v0.23.305.tar.gz"
SHA1 "fc8d7a6dac2fa23681847b3872d88d3839b657b0"
2021-07-08 00:05:39 +03:00
LOCAL
2021-06-30 03:43:36 +03:00
)
2020-01-24 19:35:49 +03:00
2021-06-30 03:43:36 +03:00
option(USE_BUNDLED_SPDLOG "Use the bundled version of spdlog." ${HUNTER_ENABLED})
2020-01-24 19:35:49 +03:00
option(USE_BUNDLED_OLM "Use the bundled version of libolm." ${HUNTER_ENABLED})
2021-06-30 03:43:36 +03:00
option(USE_BUNDLED_GTEST "Use the bundled version of Google Test." ${HUNTER_ENABLED})
option(USE_BUNDLED_CMARK "Use the bundled version of cmark." ${HUNTER_ENABLED})
option(USE_BUNDLED_JSON "Use the bundled version of nlohmann json." ${HUNTER_ENABLED})
option(USE_BUNDLED_OPENSSL "Use the bundled version of OpenSSL." OFF)
2020-01-24 19:35:49 +03:00
option(USE_BUNDLED_MTXCLIENT "Use the bundled version of the Matrix Client library." ${HUNTER_ENABLED})
2021-06-30 03:43:36 +03:00
option(USE_BUNDLED_LMDB "Use the bundled version of lmdb." ${HUNTER_ENABLED})
option(USE_BUNDLED_LMDBXX "Use the bundled version of lmdb++." ${HUNTER_ENABLED})
option(USE_BUNDLED_QTKEYCHAIN "Use the bundled version of Qt5Keychain." ${HUNTER_ENABLED})
option(USE_BUNDLED_COEURL "Use a bundled version of the Curl wrapper"
2020-12-18 05:21:17 +03:00
${HUNTER_ENABLED})
2021-06-30 03:43:36 +03:00
option(USE_BUNDLED_LIBEVENT "Use the bundled version of spdlog." ${HUNTER_ENABLED})
option(USE_BUNDLED_LIBCURL "Use the bundled version of spdlog." ${HUNTER_ENABLED})
2020-01-24 19:35:49 +03:00
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
2017-11-06 18:17:21 +03:00
2020-01-26 20:53:24 +03:00
if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
message("Adding FetchContent_MakeAvailable")
# from cmakes sources
macro(FetchContent_MakeAvailable)
foreach(contentName IN ITEMS ${ARGV})
string(TOLOWER ${contentName} contentNameLower)
FetchContent_GetProperties(${contentName})
if(NOT ${contentNameLower}_POPULATED)
FetchContent_Populate(${contentName})
# Only try to call add_subdirectory() if the populated content
# can be treated that way. Protecting the call with the check
# allows this function to be used for projects that just want
# to ensure the content exists, such as to provide content at
# a known location.
if(EXISTS ${${contentNameLower}_SOURCE_DIR}/CMakeLists.txt)
add_subdirectory(${${contentNameLower}_SOURCE_DIR}
${${contentNameLower}_BINARY_DIR})
endif()
endif()
endforeach()
endmacro()
endif()
2021-01-24 03:05:12 +03:00
# Include Qt basic functions
include(QtCommon)
2021-01-21 21:23:21 +03:00
project(nheko LANGUAGES CXX C)
2018-01-09 21:34:01 +03:00
include(GNUInstallDirs)
2018-03-22 17:20:22 +03:00
set(CPACK_PACKAGE_VERSION_MAJOR "0")
2021-01-20 03:12:13 +03:00
set(CPACK_PACKAGE_VERSION_MINOR "8")
2021-04-19 03:21:30 +03:00
set(CPACK_PACKAGE_VERSION_PATCH "2")
2018-03-22 20:13:38 +03:00
set(PROJECT_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR})
set(PROJECT_VERSION_MINOR ${CPACK_PACKAGE_VERSION_MINOR})
set(PROJECT_VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH})
2017-11-06 18:17:21 +03:00
2018-03-22 20:13:38 +03:00
# Set PROJECT_VERSION_PATCH & PROJECT_VERSION_TWEAK to 0 if not present
# Needed by add_project_meta.
2017-11-06 18:17:21 +03:00
fix_project_version()
# Set additional project information
set(COMPANY "Nheko")
2020-05-01 02:27:27 +03:00
set(COPYRIGHT "Copyright (c) 2020 Nheko Contributors")
set(IDENTIFIER "io.github.nheko-reborn.nheko")
2017-11-06 18:17:21 +03:00
add_project_meta(META_FILES_TO_INCLUDE)
2018-06-04 16:07:47 +03:00
if(NOT MSVC AND NOT APPLE)
2020-01-25 02:58:22 +03:00
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
2018-06-04 16:07:47 +03:00
endif()
2018-07-02 18:39:49 +03:00
if (BUILD_DOCS)
2020-01-25 02:58:22 +03:00
find_package(Doxygen)
if (DOXYGEN_FOUND)
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT})
add_custom_target(docs ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
2018-07-02 18:39:49 +03:00
endif()
2021-06-30 03:43:36 +03:00
#
## coeurl
#
## Need to repeat all libevent deps?!?
if (USE_BUNDLED_LIBEVENT)
hunter_add_package(Libevent)
find_package(Libevent CONFIG REQUIRED)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(libevent_core REQUIRED IMPORTED_TARGET libevent_core)
if (WIN32)
pkg_check_modules(libevent_windows REQUIRED IMPORTED_TARGET libevent_windows)
else()
pkg_check_modules(libevent_pthreads REQUIRED IMPORTED_TARGET
libevent_pthreads)
endif()
endif()
# curl
if (USE_BUNDLED_LIBCURL)
hunter_add_package(CURL)
find_package(CURL CONFIG REQUIRED)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(libcurl REQUIRED IMPORTED_TARGET libcurl)
endif()
# spdlog
if(USE_BUNDLED_SPDLOG)
hunter_add_package(spdlog)
endif()
find_package(spdlog 1.0.0 CONFIG REQUIRED)
2018-07-02 18:39:49 +03:00
2017-07-29 11:49:00 +03:00
#
# LMDB
#
2020-01-24 19:35:49 +03:00
#include(LMDB)
if(USE_BUNDLED_LMDB)
hunter_add_package(lmdb)
find_package(liblmdb CONFIG REQUIRED)
2021-03-03 06:26:55 +03:00
target_include_directories(liblmdb::lmdb INTERFACE
"${HUNTER_INSTALL_PREFIX}/include/lmdb")
2020-01-24 19:35:49 +03:00
else()
2021-04-03 15:46:03 +03:00
find_package(LMDB REQUIRED)
2020-01-24 19:35:49 +03:00
endif()
2017-07-29 11:49:00 +03:00
2017-07-09 12:49:17 +03:00
#
# Discover Qt dependencies.
#
2021-07-10 21:28:46 +03:00
find_package(Qt5 5.15 COMPONENTS Core Widgets LinguistTools Concurrent Svg Multimedia Qml QuickControls2 QuickWidgets REQUIRED)
2019-10-28 00:01:40 +03:00
find_package(Qt5QuickCompiler)
2018-07-11 17:33:02 +03:00
find_package(Qt5DBus)
2020-12-18 05:21:17 +03:00
if (USE_BUNDLED_QTKEYCHAIN)
include(FetchContent)
FetchContent_Declare(
qt5keychain
GIT_REPOSITORY https://github.com/frankosterfeld/qtkeychain.git
GIT_TAG v0.12.0
)
if (BUILD_SHARED_LIBS)
set(QTKEYCHAIN_STATIC OFF CACHE INTERNAL "")
else()
set(QTKEYCHAIN_STATIC ON CACHE INTERNAL "")
endif()
set(BUILD_TEST_APPLICATION OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(qt5keychain)
else()
2021-06-30 03:43:36 +03:00
find_package(Qt5Keychain REQUIRED)
2020-12-18 05:21:17 +03:00
endif()
2017-04-06 02:06:42 +03:00
2017-07-01 16:34:36 +03:00
if (APPLE)
2020-01-25 02:58:22 +03:00
find_package(Qt5MacExtras REQUIRED)
2017-07-01 16:34:36 +03:00
endif(APPLE)
2017-05-30 14:35:01 +03:00
if (Qt5Widgets_FOUND)
2020-10-08 18:26:07 +03:00
if (Qt5Widgets_VERSION VERSION_LESS 5.10.0)
2020-01-25 02:58:22 +03:00
message(STATUS "Qt version ${Qt5Widgets_VERSION}")
2020-10-08 18:26:07 +03:00
message(WARNING "Minimum supported Qt5 version is 5.10!")
2020-01-25 02:58:22 +03:00
endif()
2017-05-30 14:35:01 +03:00
endif(Qt5Widgets_FOUND)
2017-04-06 02:06:42 +03:00
set(CMAKE_INCLUDE_CURRENT_DIR ON)
2018-06-04 16:07:47 +03:00
if(NOT MSVC)
2020-01-25 02:58:22 +03:00
set(
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} \
-Wall \
-Wextra \
-pipe \
-pedantic \
-fsized-deallocation \
-fdiagnostics-color=always \
-Wunreachable-code \
2021-01-12 18:45:22 +03:00
-Wno-attributes"
2020-01-25 02:58:22 +03:00
)
if (NOT CMAKE_COMPILER_IS_GNUCXX)
# -Wshadow is buggy and broken in GCC, so do not enable it.
# see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79328
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
endif()
2018-06-04 16:07:47 +03:00
endif()
2017-04-06 02:06:42 +03:00
2019-01-28 05:03:07 +03:00
if (MSVC)
2020-01-25 02:58:22 +03:00
set(
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} /bigobj"
)
2019-01-28 05:03:07 +03:00
endif()
2018-06-14 02:17:38 +03:00
if(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES))
2020-01-25 02:58:22 +03:00
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
message("Setting build type to '${CMAKE_BUILD_TYPE}'")
2018-06-14 02:17:38 +03:00
else(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES))
2020-01-25 02:58:22 +03:00
message("Build type set to '${CMAKE_BUILD_TYPE}'")
2018-06-14 02:17:38 +03:00
endif(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES))
2017-04-11 18:25:39 +03:00
2018-10-06 17:45:56 +03:00
set(SPDLOG_DEBUG_ON false)
# Windows doesn't handle CMAKE_BUILD_TYPE.
if(NOT WIN32)
2021-03-28 02:25:00 +03:00
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
2020-01-25 02:58:22 +03:00
set(SPDLOG_DEBUG_ON true)
else()
set(SPDLOG_DEBUG_ON false)
endif()
2018-09-30 14:33:54 +03:00
endif()
2018-03-22 17:20:22 +03:00
find_program(GIT git)
if(GIT)
2020-01-25 02:58:22 +03:00
execute_process(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${GIT} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(GIT_OUT)
set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}-${GIT_OUT}")
else()
set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}")
endif()
2018-03-22 17:20:22 +03:00
endif(GIT)
2017-04-11 18:25:39 +03:00
set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
set(PROJECT_VERSION ${CPACK_PACKAGE_VERSION})
message(STATUS "Version: ${PROJECT_VERSION}")
2018-03-22 17:20:22 +03:00
cmake_host_system_information(RESULT BUILD_HOST QUERY HOSTNAME)
2021-06-30 16:01:41 +03:00
include(CheckSymbolExists)
check_symbol_exists(backtrace_symbols_fd "execinfo.h" HAVE_BACKTRACE_SYMBOLS_FD)
2018-09-30 14:33:54 +03:00
configure_file(cmake/nheko.h config/nheko.h)
2018-03-22 17:20:22 +03:00
2018-03-25 00:36:27 +03:00
2017-07-09 12:49:17 +03:00
#
# Declare source and header files.
#
2017-04-06 02:06:42 +03:00
set(SRC_FILES
2020-01-25 02:58:22 +03:00
# Dialogs
src/dialogs/CreateRoom.cpp
2020-02-23 13:42:29 +03:00
src/dialogs/FallbackAuth.cpp
2020-01-25 02:58:22 +03:00
src/dialogs/ImageOverlay.cpp
src/dialogs/JoinRoom.cpp
src/dialogs/LeaveRoom.cpp
src/dialogs/Logout.cpp
2020-02-23 13:42:29 +03:00
src/dialogs/PreviewUploadOverlay.cpp
2020-01-25 02:58:22 +03:00
src/dialogs/ReCaptcha.cpp
# Emoji
2020-05-13 07:35:26 +03:00
src/emoji/EmojiModel.cpp
2021-06-30 03:43:36 +03:00
src/emoji/Provider.cpp
2020-06-11 05:34:14 +03:00
2020-01-25 02:58:22 +03:00
# Timeline
2021-06-10 00:52:28 +03:00
src/timeline/CommunitiesModel.cpp
2020-07-10 00:15:22 +03:00
src/timeline/EventStore.cpp
2020-11-01 01:24:07 +03:00
src/timeline/InputBar.cpp
2020-07-19 13:22:54 +03:00
src/timeline/Reaction.cpp
2020-01-25 02:58:22 +03:00
src/timeline/TimelineViewManager.cpp
src/timeline/TimelineModel.cpp
src/timeline/DelegateChooser.cpp
2021-05-02 19:01:18 +03:00
src/timeline/Permissions.cpp
2021-05-19 20:34:10 +03:00
src/timeline/RoomlistModel.cpp
2020-01-25 02:58:22 +03:00
# UI components
src/ui/Badge.cpp
2020-01-31 08:12:02 +03:00
src/ui/DropShadow.cpp
2020-01-25 02:58:22 +03:00
src/ui/FlatButton.cpp
src/ui/FloatingButton.cpp
2020-11-25 19:02:23 +03:00
src/ui/InfoMessage.cpp
2020-01-25 02:58:22 +03:00
src/ui/Label.cpp
2020-11-25 19:02:23 +03:00
src/ui/LoadingIndicator.cpp
2021-08-29 06:20:23 +03:00
src/ui/MxcAnimatedImage.cpp
2021-08-28 01:38:33 +03:00
src/ui/MxcMediaProxy.cpp
2021-02-14 03:28:28 +03:00
src/ui/NhekoCursorShape.cpp
2020-11-25 19:02:23 +03:00
src/ui/NhekoDropArea.cpp
2021-05-13 09:23:56 +03:00
src/ui/NhekoGlobalObject.cpp
2020-01-25 02:58:22 +03:00
src/ui/OverlayModal.cpp
2020-11-25 19:02:23 +03:00
src/ui/OverlayWidget.cpp
2020-01-25 02:58:22 +03:00
src/ui/RaisedButton.cpp
src/ui/Ripple.cpp
src/ui/RippleOverlay.cpp
2021-05-13 09:23:56 +03:00
src/ui/RoomSettings.cpp
2020-11-25 19:02:23 +03:00
src/ui/SnackBar.cpp
2020-01-25 02:58:22 +03:00
src/ui/TextField.cpp
src/ui/TextLabel.cpp
src/ui/Theme.cpp
src/ui/ThemeManager.cpp
2020-11-25 19:02:23 +03:00
src/ui/ToggleButton.cpp
2021-09-18 01:21:14 +03:00
src/ui/UIA.cpp
2020-05-17 16:34:47 +03:00
src/ui/UserProfile.cpp
2020-01-25 02:58:22 +03:00
2021-06-30 03:43:36 +03:00
# Generic notification stuff
src/notifications/Manager.cpp
2021-02-16 02:36:10 +03:00
2020-01-25 02:58:22 +03:00
src/AvatarProvider.cpp
2020-03-01 21:55:43 +03:00
src/BlurhashProvider.cpp
2020-01-25 02:58:22 +03:00
src/Cache.cpp
2021-02-07 19:47:47 +03:00
src/CallDevices.cpp
2020-07-11 02:19:48 +03:00
src/CallManager.cpp
2020-01-25 02:58:22 +03:00
src/ChatPage.cpp
2021-04-29 22:46:49 +03:00
src/Clipboard.cpp
2020-03-01 21:55:43 +03:00
src/ColorImageProvider.cpp
2020-11-24 17:35:56 +03:00
src/CompletionProxyModel.cpp
2020-03-13 23:05:18 +03:00
src/DeviceVerificationFlow.cpp
2020-01-25 02:58:22 +03:00
src/EventAccessors.cpp
2021-06-11 03:13:12 +03:00
src/InviteesModel.cpp
2020-12-25 17:14:00 +03:00
src/JdenticonProvider.cpp
2020-01-25 02:58:22 +03:00
src/Logging.cpp
2020-03-01 21:55:43 +03:00
src/LoginPage.cpp
2020-01-25 02:58:22 +03:00
src/MainWindow.cpp
src/MatrixClient.cpp
2021-05-30 04:09:21 +03:00
src/MemberList.cpp
2020-01-25 02:58:22 +03:00
src/MxcImageProvider.cpp
src/Olm.cpp
2021-08-28 01:38:33 +03:00
src/ReadReceiptsModel.cpp
2020-01-25 02:58:22 +03:00
src/RegisterPage.cpp
2020-05-10 00:31:00 +03:00
src/SSOHandler.cpp
2021-07-21 02:03:38 +03:00
src/CombinedImagePackModel.cpp
2021-07-21 14:37:57 +03:00
src/SingleImagePackModel.cpp
src/ImagePackListModel.cpp
2020-01-25 02:58:22 +03:00
src/TrayIcon.cpp
src/UserSettingsPage.cpp
2020-09-07 12:51:28 +03:00
src/UsersModel.cpp
2021-07-29 05:29:57 +03:00
src/RoomDirectoryModel.cpp
2021-02-15 22:17:17 +03:00
src/RoomsModel.cpp
2020-03-01 21:55:43 +03:00
src/Utils.cpp
2021-09-18 01:21:14 +03:00
src/SelfVerificationStatus.cpp
2020-07-11 02:19:48 +03:00
src/WebRTCSession.cpp
2020-01-25 02:58:22 +03:00
src/WelcomePage.cpp
src/main.cpp
2020-03-01 21:55:43 +03:00
third_party/blurhash/blurhash.cpp
2020-01-25 02:58:22 +03:00
)
2017-04-06 02:06:42 +03:00
2018-03-29 09:59:04 +03:00
2019-02-24 22:50:31 +03:00
include(FeatureSummary)
2020-05-15 23:48:30 +03:00
2020-01-24 19:35:49 +03:00
if(USE_BUNDLED_OPENSSL)
hunter_add_package(OpenSSL)
endif()
2020-07-01 01:46:44 +03:00
find_package(OpenSSL 1.1.0 REQUIRED)
2020-01-24 19:35:49 +03:00
if(USE_BUNDLED_MTXCLIENT)
include(FetchContent)
FetchContent_Declare(
MatrixClient
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
2021-09-18 01:21:14 +03:00
GIT_TAG 8b56b466dbacde501ed9087d53bb4f51b297eca8
2020-01-24 19:35:49 +03:00
)
2020-12-18 05:21:17 +03:00
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
2020-01-24 19:35:49 +03:00
FetchContent_MakeAvailable(MatrixClient)
else()
2021-04-20 20:52:23 +03:00
find_package(MatrixClient 0.5.1 REQUIRED)
2020-01-24 19:35:49 +03:00
endif()
if(USE_BUNDLED_OLM)
include(FetchContent)
FetchContent_Declare(
Olm
GIT_REPOSITORY https://gitlab.matrix.org/matrix-org/olm.git
2021-06-14 18:41:11 +03:00
GIT_TAG 3.2.4
2020-01-24 19:35:49 +03:00
)
2020-12-18 05:21:17 +03:00
set(OLM_TESTS OFF CACHE INTERNAL "")
2020-01-24 19:35:49 +03:00
FetchContent_MakeAvailable(Olm)
else()
2021-04-03 15:46:03 +03:00
find_package(Olm 3 REQUIRED)
2020-01-24 19:35:49 +03:00
set_package_properties(Olm PROPERTIES
DESCRIPTION "An implementation of the Double Ratchet cryptographic ratchet"
URL "https://git.matrix.org/git/olm/about/"
TYPE REQUIRED
)
endif()
if(USE_BUNDLED_SPDLOG)
hunter_add_package(spdlog)
endif()
2018-08-08 14:15:14 +03:00
find_package(spdlog 1.0.0 CONFIG REQUIRED)
2020-01-24 19:35:49 +03:00
if(USE_BUNDLED_CMARK)
include(FetchContent)
FetchContent_Declare(
cmark
GIT_REPOSITORY https://github.com/commonmark/cmark.git
2020-01-25 20:48:04 +03:00
GIT_TAG 242e277a661ec7e51f34dcaf86c1925d550b1498 #0.29.0 << doesn't work with fetch content yet
2020-01-25 21:47:54 +03:00
CMAKE_ARGS "CMARK_STATIC=ON CMARK_SHARED=OFF CMARK_TESTS=OFF CMARK_TESTS=OFF"
2020-01-24 19:35:49 +03:00
)
FetchContent_MakeAvailable(cmark)
2020-01-26 17:44:56 +03:00
if (MSVC)
add_library(cmark::cmark ALIAS libcmark)
else()
add_library(cmark::cmark ALIAS libcmark_static)
endif()
2020-01-24 19:35:49 +03:00
else()
2020-04-16 00:29:53 +03:00
find_package(cmark REQUIRED 0.29.0)
2020-01-24 19:35:49 +03:00
endif()
if(USE_BUNDLED_JSON)
hunter_add_package(nlohmann_json)
endif()
2019-02-24 22:50:31 +03:00
find_package(nlohmann_json 3.2.0)
set_package_properties(nlohmann_json PROPERTIES
2020-01-25 02:58:22 +03:00
DESCRIPTION "JSON for Modern C++, a C++11 header-only JSON class"
URL "https://nlohmann.github.io/json/"
TYPE REQUIRED
)
2018-03-03 14:02:33 +03:00
2020-01-24 19:35:49 +03:00
if(USE_BUNDLED_LMDBXX)
2021-03-07 04:18:41 +03:00
include(FetchContent)
2021-03-03 01:15:12 +03:00
FetchContent_Declare(
2021-06-30 03:43:36 +03:00
lmdbxx
URL "https://raw.githubusercontent.com/hoytech/lmdbxx/1.0.0/lmdb++.h"
DOWNLOAD_NO_EXTRACT TRUE
)
2021-03-03 01:15:12 +03:00
if(NOT lmdbxx_POPULATED)
FetchContent_Populate(lmdbxx)
endif()
add_library(lmdbxx INTERFACE)
target_include_directories(lmdbxx INTERFACE ${lmdbxx_SOURCE_DIR})
add_library(lmdbxx::lmdbxx ALIAS lmdbxx)
2020-01-24 19:35:49 +03:00
else()
if(NOT LMDBXX_INCLUDE_DIR)
find_path(LMDBXX_INCLUDE_DIR
NAMES lmdb++.h
PATHS /usr/include
/usr/local/include
$ENV{LIB_DIR}/include
$ENV{LIB_DIR}/include/lmdbxx)
endif()
add_library(lmdbxx INTERFACE)
target_include_directories(lmdbxx INTERFACE ${LMDBXX_INCLUDE_DIR})
add_library(lmdbxx::lmdbxx ALIAS lmdbxx)
2018-03-29 09:59:04 +03:00
endif()
2017-08-06 11:01:46 +03:00
2020-07-11 02:19:48 +03:00
include(FindPkgConfig)
2021-02-21 01:14:22 +03:00
pkg_check_modules(GSTREAMER IMPORTED_TARGET gstreamer-sdp-1.0>=1.18 gstreamer-webrtc-1.0>=1.18)
2021-01-06 18:47:35 +03:00
if (TARGET PkgConfig::GSTREAMER)
2021-01-07 18:13:33 +03:00
add_feature_info(voip ON "GStreamer found. Call support is enabled automatically.")
2021-02-25 21:27:22 +03:00
pkg_check_modules(XCB IMPORTED_TARGET xcb xcb-ewmh)
if (TARGET PkgConfig::XCB)
add_feature_info("Window selection when screen sharing (X11)" ON "XCB-EWMH found. Window selection is enabled when screen sharing (X11).")
else()
add_feature_info("Window selection when screen sharing (X11)" OFF "XCB-EWMH could not be found on your system. Screen sharing (X11) is limited to the entire screen only. To enable window selection, make sure xcb and xcb-ewmh can be found via pkgconfig.")
endif()
2021-01-06 18:47:35 +03:00
else()
2021-02-21 01:14:22 +03:00
add_feature_info(voip OFF "GStreamer could not be found on your system. As a consequence call support has been disabled. If you don't want that, make sure gstreamer-sdp-1.0>=1.18 gstreamer-webrtc-1.0>=1.18 can be found via pkgconfig.")
2021-01-06 18:47:35 +03:00
endif()
2020-07-11 02:19:48 +03:00
2020-02-23 15:40:04 +03:00
# single instance functionality
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
2021-06-16 23:30:45 +03:00
add_subdirectory(third_party/SingleApplication-3.3.0/)
2020-02-23 15:40:04 +03:00
2019-02-24 22:50:31 +03:00
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
2017-04-06 02:06:42 +03:00
qt5_wrap_cpp(MOC_HEADERS
2020-01-25 02:58:22 +03:00
# Dialogs
src/dialogs/CreateRoom.h
2020-02-23 13:42:29 +03:00
src/dialogs/FallbackAuth.h
2020-01-25 02:58:22 +03:00
src/dialogs/ImageOverlay.h
src/dialogs/JoinRoom.h
src/dialogs/LeaveRoom.h
src/dialogs/Logout.h
2020-02-23 13:42:29 +03:00
src/dialogs/PreviewUploadOverlay.h
2020-01-25 02:58:22 +03:00
src/dialogs/ReCaptcha.h
# Emoji
2020-05-13 07:35:26 +03:00
src/emoji/EmojiModel.h
src/emoji/Provider.h
2020-01-25 02:58:22 +03:00
# Timeline
2021-06-10 00:52:28 +03:00
src/timeline/CommunitiesModel.h
2020-07-10 00:15:22 +03:00
src/timeline/EventStore.h
2020-11-01 01:24:07 +03:00
src/timeline/InputBar.h
2020-07-19 13:22:54 +03:00
src/timeline/Reaction.h
2020-01-25 02:58:22 +03:00
src/timeline/TimelineViewManager.h
src/timeline/TimelineModel.h
src/timeline/DelegateChooser.h
2021-05-02 19:01:18 +03:00
src/timeline/Permissions.h
2021-05-19 20:34:10 +03:00
src/timeline/RoomlistModel.h
2020-01-25 02:58:22 +03:00
# UI components
src/ui/Badge.h
src/ui/FlatButton.h
src/ui/FloatingButton.h
2021-05-13 09:23:56 +03:00
src/ui/InfoMessage.h
src/ui/Label.h
src/ui/LoadingIndicator.h
2021-08-29 06:20:23 +03:00
src/ui/MxcAnimatedImage.h
2021-08-28 01:38:33 +03:00
src/ui/MxcMediaProxy.h
2020-01-25 02:58:22 +03:00
src/ui/Menu.h
2021-02-14 03:28:28 +03:00
src/ui/NhekoCursorShape.h
2020-11-25 19:02:23 +03:00
src/ui/NhekoDropArea.h
2021-05-13 09:23:56 +03:00
src/ui/NhekoGlobalObject.h
2020-01-25 02:58:22 +03:00
src/ui/OverlayWidget.h
src/ui/RaisedButton.h
src/ui/Ripple.h
src/ui/RippleOverlay.h
2021-05-13 09:23:56 +03:00
src/ui/RoomSettings.h
src/ui/SnackBar.h
2020-01-25 02:58:22 +03:00
src/ui/TextField.h
src/ui/TextLabel.h
src/ui/Theme.h
src/ui/ThemeManager.h
2021-05-13 09:23:56 +03:00
src/ui/ToggleButton.h
2021-09-18 01:21:14 +03:00
src/ui/UIA.h
2020-05-17 16:34:47 +03:00
src/ui/UserProfile.h
2020-01-25 02:58:22 +03:00
src/notifications/Manager.h
src/AvatarProvider.h
2020-03-04 03:56:58 +03:00
src/BlurhashProvider.h
2021-05-07 13:19:46 +03:00
src/CacheCryptoStructs.h
2021-08-07 23:51:09 +03:00
src/Cache_p.h
2021-02-07 19:47:47 +03:00
src/CallDevices.h
2020-07-11 02:19:48 +03:00
src/CallManager.h
2020-01-25 02:58:22 +03:00
src/ChatPage.h
2021-04-29 22:46:49 +03:00
src/Clipboard.h
2021-08-07 23:51:09 +03:00
src/CombinedImagePackModel.h
2020-11-20 04:38:08 +03:00
src/CompletionProxyModel.h
2020-03-13 23:05:18 +03:00
src/DeviceVerificationFlow.h
2021-08-07 23:51:09 +03:00
src/ImagePackListModel.h
2021-06-11 03:13:12 +03:00
src/InviteesModel.h
2020-12-25 17:14:00 +03:00
src/JdenticonProvider.h
2020-01-25 02:58:22 +03:00
src/LoginPage.h
src/MainWindow.h
2021-05-30 04:09:21 +03:00
src/MemberList.h
2020-01-25 02:58:22 +03:00
src/MxcImageProvider.h
2021-08-07 23:51:09 +03:00
src/Olm.h
2020-01-25 02:58:22 +03:00
src/RegisterPage.h
2021-08-07 23:51:09 +03:00
src/RoomsModel.h
2020-05-10 00:31:00 +03:00
src/SSOHandler.h
2021-07-21 14:37:57 +03:00
src/SingleImagePackModel.h
2020-01-25 02:58:22 +03:00
src/TrayIcon.h
src/UserSettingsPage.h
2020-11-20 04:38:08 +03:00
src/UsersModel.h
2021-07-29 05:29:57 +03:00
src/RoomDirectoryModel.h
2021-08-09 16:18:08 +03:00
src/RoomsModel.h
2021-09-18 01:21:14 +03:00
src/SelfVerificationStatus.h
2020-07-11 02:19:48 +03:00
src/WebRTCSession.h
2020-01-25 02:58:22 +03:00
src/WelcomePage.h
2021-08-07 23:51:09 +03:00
src/ReadReceiptsModel.h
)
2017-04-06 02:06:42 +03:00
2017-07-09 12:49:17 +03:00
#
# Bundle translations.
#
2018-03-29 09:59:04 +03:00
include(Translations)
set(TRANSLATION_DEPS ${LANG_QRC} ${QRC} ${QM_SRC})
2017-05-29 19:09:12 +03:00
2018-05-05 22:40:24 +03:00
if (APPLE)
2020-01-25 02:58:22 +03:00
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation -framework Cocoa")
2021-02-16 02:36:10 +03:00
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerMac.mm src/notifications/ManagerMac.cpp src/emoji/MacHelper.mm)
2020-05-30 17:53:57 +03:00
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
set_source_files_properties( src/notifications/ManagerMac.mm src/emoji/MacHelper.mm PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
endif()
2018-05-05 22:40:24 +03:00
elseif (WIN32)
2020-01-25 02:58:22 +03:00
file(DOWNLOAD
"https://raw.githubusercontent.com/mohabouje/WinToast/41ed1c58d5dce0ee9c01dbdeac05be45358d4f57/src/wintoastlib.cpp"
${PROJECT_SOURCE_DIR}/src/wintoastlib.cpp
EXPECTED_HASH SHA256=1A1A7CE41C1052B12946798F4A6C67CE1FAD209C967F5ED4D720B173527E2073)
2018-07-01 00:23:16 +03:00
2020-01-25 02:58:22 +03:00
file(DOWNLOAD
"https://raw.githubusercontent.com/mohabouje/WinToast/41ed1c58d5dce0ee9c01dbdeac05be45358d4f57/src/wintoastlib.h"
${PROJECT_SOURCE_DIR}/src/wintoastlib.h
EXPECTED_HASH SHA256=b4481023c5782733795838be22bf1a75f45d87458cd4d9a5a75f664a146eea11)
2018-07-01 00:23:16 +03:00
2020-01-25 02:58:22 +03:00
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerWin.cpp src/wintoastlib.cpp)
2018-05-05 22:40:24 +03:00
else ()
2020-01-25 02:58:22 +03:00
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerLinux.cpp)
2018-05-05 22:40:24 +03:00
endif ()
2018-03-29 09:59:04 +03:00
set(NHEKO_DEPS
2020-01-25 02:58:22 +03:00
${SRC_FILES}
${UI_HEADERS}
${MOC_HEADERS}
${TRANSLATION_DEPS}
${META_FILES_TO_INCLUDE})
2017-10-08 16:49:56 +03:00
2018-05-04 18:11:03 +03:00
if(ASAN)
2020-01-25 02:58:22 +03:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined")
2018-05-04 18:11:03 +03:00
endif()
2020-03-23 13:09:27 +03:00
if(WIN32)
add_executable (nheko WIN32 ${OS_BUNDLE} ${NHEKO_DEPS})
2020-12-25 03:08:06 +03:00
target_compile_definitions(nheko PRIVATE _WIN32_WINNT=0x0601)
2020-03-23 13:09:27 +03:00
else()
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS})
2021-06-30 16:01:41 +03:00
if (HAVE_BACKTRACE_SYMBOLS_FD AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
set_target_properties(nheko PROPERTIES ENABLE_EXPORTS ON)
endif()
2020-03-23 13:09:27 +03:00
endif()
2017-10-08 16:49:56 +03:00
if(APPLE)
2020-01-25 02:58:22 +03:00
target_link_libraries (nheko PRIVATE Qt5::MacExtras)
2017-10-08 16:49:56 +03:00
elseif(WIN32)
2020-01-25 02:58:22 +03:00
target_compile_definitions(nheko PRIVATE WIN32_LEAN_AND_MEAN)
target_link_libraries (nheko PRIVATE ${NTDLIB} Qt5::WinMain)
2021-03-05 17:23:48 +03:00
if(MSVC)
target_compile_options(nheko PUBLIC "/Zc:__cplusplus")
endif()
2017-10-08 16:49:56 +03:00
else()
2020-01-25 02:58:22 +03:00
target_link_libraries (nheko PRIVATE Qt5::DBus)
2017-05-02 04:22:33 +03:00
endif()
2020-05-10 00:31:00 +03:00
target_include_directories(nheko PRIVATE src includes third_party/blurhash third_party/cpp-httplib-0.5.12)
2018-01-09 21:34:01 +03:00
2020-12-18 05:21:17 +03:00
# Fixup bundled keychain include dirs
if (USE_BUNDLED_QTKEYCHAIN)
2021-06-30 03:43:36 +03:00
target_include_directories(nheko PRIVATE ${qt5keychain_SOURCE_DIR} ${qt5keychain_BINARY_DIR})
2020-12-18 05:21:17 +03:00
endif()
2020-01-25 02:58:22 +03:00
target_link_libraries(nheko PRIVATE
MatrixClient::MatrixClient
cmark::cmark
spdlog::spdlog
Qt5::Widgets
Qt5::Svg
Qt5::Concurrent
Qt5::Multimedia
Qt5::Qml
Qt5::QuickControls2
Qt5::QuickWidgets
2020-12-17 00:10:09 +03:00
qt5keychain
2020-01-25 02:58:22 +03:00
nlohmann_json::nlohmann_json
lmdbxx::lmdbxx
2020-02-14 02:32:08 +03:00
liblmdb::lmdb
2020-02-23 15:40:04 +03:00
SingleApplication::SingleApplication)
2020-01-25 02:58:22 +03:00
2020-05-25 14:02:31 +03:00
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
2021-06-30 03:43:36 +03:00
target_precompile_headers(nheko
PRIVATE
<string>
<algorithm>
)
2020-05-25 14:02:31 +03:00
endif()
2020-08-14 02:03:27 +03:00
if (TARGET PkgConfig::GSTREAMER)
target_link_libraries(nheko PRIVATE PkgConfig::GSTREAMER)
target_compile_definitions(nheko PRIVATE GSTREAMER_AVAILABLE)
2021-02-25 01:07:01 +03:00
if (TARGET PkgConfig::XCB)
target_link_libraries(nheko PRIVATE PkgConfig::XCB)
target_compile_definitions(nheko PRIVATE XCB_AVAILABLE)
endif()
2020-08-14 02:03:27 +03:00
endif()
2021-06-30 03:43:36 +03:00
if(USE_BUNDLED_COEURL)
include(FetchContent)
FetchContent_Declare(
coeurl
GIT_REPOSITORY https://nheko.im/Nheko-Reborn/coeurl.git
2021-08-12 02:29:43 +03:00
GIT_TAG 3901507db25cf3f9364b58cd8c7880640900c992
2021-06-30 03:43:36 +03:00
)
FetchContent_MakeAvailable(coeurl)
target_link_libraries(nheko PUBLIC coeurl::coeurl)
elseif(coeurl_DIR)
find_package(coeurl CONFIG REQUIRED)
target_link_libraries(nheko PUBLIC coeurl::coeurl)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(coeurl REQUIRED IMPORTED_TARGET coeurl)
target_link_libraries(nheko PUBLIC PkgConfig::coeurl)
endif()
2020-02-14 02:32:08 +03:00
if(MSVC)
target_link_libraries(nheko PRIVATE ntdll)
2020-01-25 02:58:22 +03:00
endif()
2019-12-15 01:48:02 +03:00
if(QML_DEBUGGING)
target_compile_definitions(nheko PRIVATE QML_DEBUGGING)
endif()
2020-01-25 02:58:22 +03:00
2021-02-03 23:39:49 +03:00
if(NOT MSVC AND NOT HAIKU)
2020-01-25 02:58:22 +03:00
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR CI_BUILD)
target_compile_options(nheko PRIVATE "-Werror")
endif()
endif()
2019-06-26 13:27:43 +03:00
set_target_properties(nheko PROPERTIES SKIP_BUILD_RPATH TRUE)
2018-01-09 21:34:01 +03:00
if(UNIX AND NOT APPLE)
2020-01-25 02:58:22 +03:00
install (TARGETS nheko RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install (FILES "resources/nheko-16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "nheko.png")
install (FILES "resources/nheko-32.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps" RENAME "nheko.png")
install (FILES "resources/nheko-48.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" RENAME "nheko.png")
install (FILES "resources/nheko-64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/64x64/apps" RENAME "nheko.png")
install (FILES "resources/nheko-128.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps" RENAME "nheko.png")
install (FILES "resources/nheko-256.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps" RENAME "nheko.png")
install (FILES "resources/nheko-512.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/512x512/apps" RENAME "nheko.png")
2020-01-31 04:30:09 +03:00
install (FILES "resources/nheko.svg" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps" RENAME "nheko.svg")
2020-01-25 02:58:22 +03:00
install (FILES "resources/nheko.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
install (FILES "resources/nheko.appdata.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo")
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
2018-01-09 21:34:01 +03:00
endif()