2022-08-29 18:34:25 +00:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
2022-06-03 06:44:48 +00:00
|
|
|
project(squawk VERSION 0.2.3 LANGUAGES CXX)
|
2019-03-29 14:54:34 +00:00
|
|
|
|
2021-05-11 17:29:08 +00:00
|
|
|
cmake_policy(SET CMP0076 NEW)
|
2023-08-15 15:28:25 +00:00
|
|
|
cmake_policy(SET CMP0077 NEW)
|
2021-05-11 17:29:08 +00:00
|
|
|
cmake_policy(SET CMP0079 NEW)
|
2021-03-22 18:04:26 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2019-10-05 11:27:39 +00:00
|
|
|
|
2022-08-29 18:34:25 +00:00
|
|
|
set(QT_VERSION_MAJOR 5)
|
2019-03-29 14:54:34 +00:00
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
2019-06-21 19:33:38 +00:00
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
|
2021-05-11 19:21:25 +00:00
|
|
|
include(GNUInstallDirs)
|
2021-05-11 17:29:08 +00:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
|
|
|
|
2021-10-05 04:49:06 +00:00
|
|
|
set(WIN32_FLAG "")
|
2021-10-05 16:48:25 +00:00
|
|
|
set(MACOSX_BUNDLE_FLAG "")
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
if (WIN32)
|
|
|
|
set(WIN32_FLAG WIN32)
|
|
|
|
endif(WIN32)
|
|
|
|
if (APPLE)
|
|
|
|
set(MACOSX_BUNDLE_FLAG MACOSX_BUNDLE)
|
|
|
|
endif(APPLE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_executable(squawk ${WIN32_FLAG} ${MACOSX_BUNDLE_FLAG})
|
2021-05-11 19:21:25 +00:00
|
|
|
target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR})
|
2019-10-07 15:35:55 +00:00
|
|
|
|
2021-05-11 18:35:12 +00:00
|
|
|
option(SYSTEM_QXMPP "Use system qxmpp lib" ON)
|
2023-03-27 18:45:29 +00:00
|
|
|
option(SYSTEM_LMDBAL "Use system lmdbal lib" ON)
|
2021-05-11 18:35:12 +00:00
|
|
|
option(WITH_KWALLET "Build KWallet support module" ON)
|
|
|
|
option(WITH_KIO "Build KIO support module" ON)
|
2022-01-26 20:53:44 +00:00
|
|
|
option(WITH_KCONFIG "Build KConfig support module" ON)
|
2022-08-29 18:34:25 +00:00
|
|
|
option(WITH_OMEMO "Build OMEMO support module" ON)
|
2021-05-11 18:35:12 +00:00
|
|
|
|
|
|
|
# Dependencies
|
|
|
|
## Qt
|
2022-09-03 11:39:42 +00:00
|
|
|
if (NOT DEFINED QT_VERSION_MAJOR)
|
|
|
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets DBus Gui Xml Network Core)
|
|
|
|
else ()
|
|
|
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets DBus Gui Xml Network Core)
|
|
|
|
endif()
|
|
|
|
|
2021-09-21 22:17:43 +00:00
|
|
|
find_package(Boost COMPONENTS)
|
|
|
|
|
|
|
|
target_include_directories(squawk PRIVATE ${Boost_INCLUDE_DIRS})
|
2022-08-29 18:34:25 +00:00
|
|
|
target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}_INCLUDE_DIRS})
|
|
|
|
target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS})
|
|
|
|
target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}DBus_INCLUDE_DIRS})
|
|
|
|
target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Gui_INCLUDE_DIRS})
|
|
|
|
target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Xml_INCLUDE_DIRS})
|
|
|
|
target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Network_INCLUDE_DIRS})
|
|
|
|
target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
#OMEMO
|
|
|
|
if (WITH_OMEMO)
|
|
|
|
find_package(PkgConfig)
|
|
|
|
if (PKG_CONFIG_FOUND)
|
2022-09-03 11:39:42 +00:00
|
|
|
pkg_check_modules(OMEMO libomemo-c)
|
2022-08-29 18:34:25 +00:00
|
|
|
if (OMEMO_FOUND)
|
2023-11-02 22:55:11 +00:00
|
|
|
target_compile_definitions(squawk PRIVATE WITH_OMEMO)
|
2022-09-03 11:39:42 +00:00
|
|
|
message("Building with support of OMEMO")
|
2022-08-29 18:34:25 +00:00
|
|
|
else ()
|
2022-09-03 11:39:42 +00:00
|
|
|
message("libomemo-c package wasn't found, trying to build without OMEMO support")
|
2022-08-29 18:34:25 +00:00
|
|
|
set(WITH_OMEMO OFF)
|
|
|
|
endif ()
|
|
|
|
else ()
|
2022-09-03 11:39:42 +00:00
|
|
|
message("PKG_CONFIG module wasn't found, can not check libomemo-c support, trying to build without OMEMO support")
|
2022-08-29 18:34:25 +00:00
|
|
|
set(WITH_OMEMO OFF)
|
|
|
|
endif ()
|
|
|
|
endif ()
|
2021-05-11 18:35:12 +00:00
|
|
|
|
|
|
|
## QXmpp
|
|
|
|
if (SYSTEM_QXMPP)
|
2023-11-02 22:55:11 +00:00
|
|
|
if (WITH_OMEMO)
|
|
|
|
find_package(QXmpp CONFIG COMPONENTS Omemo)
|
|
|
|
else ()
|
|
|
|
find_package(QXmpp CONFIG)
|
|
|
|
endif ()
|
2021-05-11 18:35:12 +00:00
|
|
|
|
|
|
|
if (NOT QXmpp_FOUND)
|
|
|
|
set(SYSTEM_QXMPP OFF)
|
|
|
|
message("QXmpp package wasn't found, trying to build with bundled QXmpp")
|
2021-05-11 19:24:55 +00:00
|
|
|
else ()
|
2021-05-11 18:35:12 +00:00
|
|
|
message("Building with system QXmpp")
|
2021-05-11 19:24:55 +00:00
|
|
|
endif ()
|
|
|
|
endif ()
|
2021-05-11 18:35:12 +00:00
|
|
|
|
|
|
|
## KIO
|
|
|
|
if (WITH_KIO)
|
|
|
|
find_package(KF5KIO CONFIG)
|
|
|
|
|
|
|
|
if (NOT KF5KIO_FOUND)
|
|
|
|
set(WITH_KIO OFF)
|
|
|
|
message("KIO package wasn't found, KIO support modules wouldn't be built")
|
2021-05-11 19:24:55 +00:00
|
|
|
else ()
|
2021-05-11 19:21:25 +00:00
|
|
|
target_compile_definitions(squawk PRIVATE WITH_KIO)
|
2021-05-11 18:35:12 +00:00
|
|
|
message("Building with support of KIO")
|
2021-05-11 19:24:55 +00:00
|
|
|
endif ()
|
|
|
|
endif ()
|
2021-05-11 18:35:12 +00:00
|
|
|
|
|
|
|
## KWallet
|
|
|
|
if (WITH_KWALLET)
|
|
|
|
find_package(KF5Wallet CONFIG)
|
|
|
|
|
|
|
|
if (NOT KF5Wallet_FOUND)
|
|
|
|
set(WITH_KWALLET OFF)
|
|
|
|
message("KWallet package wasn't found, KWallet support module wouldn't be built")
|
2021-05-11 19:24:55 +00:00
|
|
|
else ()
|
2021-05-11 19:21:25 +00:00
|
|
|
target_compile_definitions(squawk PRIVATE WITH_KWALLET)
|
2021-05-11 18:35:12 +00:00
|
|
|
message("Building with support of KWallet")
|
2021-05-11 19:24:55 +00:00
|
|
|
endif ()
|
|
|
|
endif ()
|
2021-05-11 18:35:12 +00:00
|
|
|
|
2022-01-26 20:53:44 +00:00
|
|
|
if (WITH_KCONFIG)
|
|
|
|
find_package(KF5Config CONFIG)
|
|
|
|
if (NOT KF5Config_FOUND)
|
|
|
|
set(WITH_KCONFIG OFF)
|
|
|
|
message("KConfig package wasn't found, KConfig support modules wouldn't be built")
|
|
|
|
else()
|
|
|
|
find_package(KF5ConfigWidgets CONFIG)
|
|
|
|
if (NOT KF5ConfigWidgets_FOUND)
|
|
|
|
set(WITH_KCONFIG OFF)
|
|
|
|
message("KConfigWidgets package wasn't found, KConfigWidgets support modules wouldn't be built")
|
|
|
|
else()
|
|
|
|
target_compile_definitions(squawk PRIVATE WITH_KCONFIG)
|
|
|
|
message("Building with support of KConfig")
|
|
|
|
message("Building with support of KConfigWidgets")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2022-08-29 18:34:25 +00:00
|
|
|
if (NOT SYSTEM_QXMPP)
|
|
|
|
message("Building with bundled QXmpp")
|
|
|
|
|
2022-09-03 11:39:42 +00:00
|
|
|
target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}/external/qxmpp/src/base)
|
|
|
|
target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}/external/qxmpp/src/client)
|
2023-01-29 17:26:54 +00:00
|
|
|
target_include_directories(squawk PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/external/qxmpp/src)
|
2022-09-03 11:39:42 +00:00
|
|
|
|
2022-08-29 18:34:25 +00:00
|
|
|
if (WITH_OMEMO)
|
2022-09-03 11:39:42 +00:00
|
|
|
target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}/external/qxmpp/src/omemo)
|
|
|
|
target_include_directories(squawk PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/external/qxmpp/src/omemo)
|
2022-08-29 18:34:25 +00:00
|
|
|
set(BUILD_OMEMO ON)
|
|
|
|
else ()
|
|
|
|
set(BUILD_OMEMO OFF)
|
|
|
|
endif ()
|
|
|
|
add_subdirectory(external/qxmpp)
|
|
|
|
|
2023-04-15 18:07:27 +00:00
|
|
|
target_link_libraries(squawk PRIVATE QXmppQt${QT_VERSION_MAJOR})
|
|
|
|
if (WITH_OMEMO)
|
|
|
|
target_link_libraries(squawk PRIVATE QXmppOmemoQt${QT_VERSION_MAJOR})
|
|
|
|
endif ()
|
2022-08-29 18:34:25 +00:00
|
|
|
else ()
|
|
|
|
target_link_libraries(squawk PRIVATE QXmpp::QXmpp)
|
2023-11-02 22:55:11 +00:00
|
|
|
if (WITH_OMEMO)
|
|
|
|
target_link_libraries(squawk PRIVATE QXmpp::Omemo)
|
|
|
|
endif ()
|
2022-08-29 18:34:25 +00:00
|
|
|
endif ()
|
2021-05-11 19:21:25 +00:00
|
|
|
|
2023-03-27 18:45:29 +00:00
|
|
|
## LMDBAL
|
|
|
|
if (SYSTEM_LMDBAL)
|
2023-04-15 18:07:27 +00:00
|
|
|
find_package(lmdbal)
|
|
|
|
if (NOT lmdbal_FOUND)
|
2023-03-27 18:45:29 +00:00
|
|
|
set(SYSTEM_LMDBAL OFF)
|
|
|
|
message("LMDBAL package wasn't found, trying to build with bundled LMDBAL")
|
|
|
|
else ()
|
|
|
|
message("Building with system LMDBAL")
|
|
|
|
endif ()
|
|
|
|
endif()
|
2022-12-14 23:08:08 +00:00
|
|
|
|
2023-03-27 18:45:29 +00:00
|
|
|
if (NOT SYSTEM_LMDBAL)
|
|
|
|
message("Building with bundled LMDBAL")
|
|
|
|
set(BUILD_STATIC ON)
|
|
|
|
add_subdirectory(external/lmdbal)
|
|
|
|
add_library(LMDBAL::LMDBAL ALIAS LMDBAL)
|
|
|
|
endif()
|
2022-12-14 23:08:08 +00:00
|
|
|
|
2023-03-27 18:45:29 +00:00
|
|
|
target_link_libraries(squawk PRIVATE LMDBAL::LMDBAL)
|
2021-05-11 19:21:25 +00:00
|
|
|
|
2021-05-11 18:35:12 +00:00
|
|
|
# Linking
|
2022-08-29 18:34:25 +00:00
|
|
|
target_link_libraries(squawk
|
|
|
|
PRIVATE
|
|
|
|
Qt${QT_VERSION_MAJOR}::Core
|
|
|
|
Qt${QT_VERSION_MAJOR}::Widgets
|
|
|
|
Qt${QT_VERSION_MAJOR}::DBus
|
|
|
|
Qt${QT_VERSION_MAJOR}::Network
|
|
|
|
Qt${QT_VERSION_MAJOR}::Gui
|
|
|
|
Qt${QT_VERSION_MAJOR}::Xml
|
|
|
|
)
|
2021-05-11 18:35:12 +00:00
|
|
|
target_link_libraries(squawk PRIVATE lmdb)
|
|
|
|
target_link_libraries(squawk PRIVATE simpleCrypt)
|
2021-10-05 17:33:58 +00:00
|
|
|
# Link thread libraries on Linux
|
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
target_link_libraries(squawk PRIVATE Threads::Threads)
|
|
|
|
endif()
|
2021-05-11 18:35:12 +00:00
|
|
|
|
|
|
|
# Build type
|
2021-05-11 19:24:55 +00:00
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
2019-11-15 13:30:29 +00:00
|
|
|
set(CMAKE_BUILD_TYPE Debug)
|
2021-05-11 19:24:55 +00:00
|
|
|
endif ()
|
2019-11-15 13:30:29 +00:00
|
|
|
|
|
|
|
message("Build type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
2021-10-05 15:45:37 +00:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
2022-01-11 20:50:42 +00:00
|
|
|
set (COMPILE_OPTIONS -fno-sized-deallocation) # for eliminating _ZdlPvm
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
list(APPEND COMPILE_OPTIONS -O3)
|
|
|
|
endif()
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL Debug)
|
|
|
|
list(APPEND COMPILE_OPTIONS -g)
|
|
|
|
list(APPEND COMPILE_OPTIONS -Wall)
|
|
|
|
list(APPEND COMPILE_OPTIONS -Wextra)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message("Compilation options: " ${COMPILE_OPTIONS})
|
|
|
|
target_compile_options(squawk PRIVATE ${COMPILE_OPTIONS})
|
2021-10-05 15:45:37 +00:00
|
|
|
endif(CMAKE_COMPILER_IS_GNUCXX)
|
2020-04-03 22:28:15 +00:00
|
|
|
|
2022-04-22 15:26:18 +00:00
|
|
|
add_subdirectory(main)
|
2019-10-10 11:45:21 +00:00
|
|
|
add_subdirectory(core)
|
2020-04-07 20:33:03 +00:00
|
|
|
add_subdirectory(external/simpleCrypt)
|
2021-05-11 19:21:25 +00:00
|
|
|
add_subdirectory(packaging)
|
|
|
|
add_subdirectory(plugins)
|
|
|
|
add_subdirectory(resources)
|
|
|
|
add_subdirectory(shared)
|
|
|
|
add_subdirectory(translations)
|
|
|
|
add_subdirectory(ui)
|
2019-10-05 11:27:39 +00:00
|
|
|
|
2019-03-29 14:54:34 +00:00
|
|
|
# Install the executable
|
2019-10-07 15:35:55 +00:00
|
|
|
install(TARGETS squawk DESTINATION ${CMAKE_INSTALL_BINDIR})
|
2022-04-05 19:00:56 +00:00
|
|
|
install(FILES README.md DESTINATION ${CMAKE_INSTALL_DATADIR}/macaw.me/squawk)
|
|
|
|
install(FILES LICENSE.md DESTINATION ${CMAKE_INSTALL_DATADIR}/macaw.me/squawk)
|
2021-10-05 15:45:37 +00:00
|
|
|
|
2021-10-06 09:32:46 +00:00
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
if (APPLE)
|
|
|
|
add_custom_command(TARGET squawk POST_BUILD COMMENT "Running macdeployqt..."
|
2022-08-29 18:34:25 +00:00
|
|
|
COMMAND "${Qt${QT_VERSION_MAJOR}Widgets_DIR}/../../../bin/macdeployqt" "${CMAKE_CURRENT_BINARY_DIR}/squawk.app"
|
2021-10-06 09:32:46 +00:00
|
|
|
)
|
|
|
|
endif(APPLE)
|
|
|
|
endif()
|
|
|
|
|