abaddon/CMakeLists.txt

224 lines
7.8 KiB
CMake
Raw Normal View History

2020-09-09 21:03:19 +00:00
cmake_minimum_required(VERSION 3.16)
project(abaddon)
2021-07-03 01:41:05 +00:00
set(ABADDON_RESOURCE_DIR "/usr/share/abaddon" CACHE PATH "Fallback directory for resources on Linux")
2020-09-09 21:03:19 +00:00
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
2020-09-09 21:03:19 +00:00
2022-04-08 18:50:11 +00:00
option(USE_LIBHANDY "Enable features that require libhandy (default)" ON)
2022-08-28 20:58:09 +00:00
option(ENABLE_VOICE "Enable voice suppport" ON)
2022-08-09 02:50:27 +00:00
option(USE_KEYCHAIN "Store the token in the keychain (default)" ON)
option(ENABLE_NOTIFICATION_SOUNDS "Enable notification sounds (default)" ON)
2023-05-28 06:13:36 +00:00
option(ENABLE_RNNOISE "Enable RNNoise for voice activity detection (default)" ON)
2023-07-10 02:31:21 +00:00
option(ENABLE_QRCODE_LOGIN "Enable QR code login (default)" ON)
2022-04-08 18:50:11 +00:00
find_package(nlohmann_json REQUIRED)
find_package(CURL)
find_package(ZLIB REQUIRED)
find_package(SQLite3 REQUIRED)
find_package(gtkmm REQUIRED)
2020-10-12 22:17:53 +00:00
set(USE_TLS TRUE)
set(USE_OPEN_SSL TRUE)
find_package(IXWebSocket QUIET)
if (NOT IXWebSocket_FOUND)
2022-04-08 18:50:11 +00:00
message("ixwebsocket was not found and will be included as a submodule")
add_subdirectory(subprojects/ixwebsocket)
include_directories(IXWEBSOCKET_INCLUDE_DIRS)
endif ()
2020-09-09 21:03:19 +00:00
2022-04-08 18:50:11 +00:00
if (MINGW OR WIN32)
link_libraries(ws2_32)
endif ()
2020-09-09 21:03:19 +00:00
2022-04-08 18:50:11 +00:00
if (WIN32)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
add_compile_definitions(NOMINMAX)
endif ()
2020-12-22 07:35:57 +00:00
include(TestBigEndian)
test_big_endian(IS_BIG_ENDIAN)
if (IS_BIG_ENDIAN)
add_compile_definitions(ABADDON_IS_BIG_ENDIAN)
endif ()
configure_file(${PROJECT_SOURCE_DIR}/src/config.h.in ${PROJECT_BINARY_DIR}/config.h)
2021-07-03 01:41:05 +00:00
file(GLOB_RECURSE ABADDON_SOURCES
2022-04-08 18:50:11 +00:00
"src/*.h"
"src/*.hpp"
"src/*.cpp"
)
2020-11-01 04:33:57 +00:00
2023-03-01 01:23:34 +00:00
list(FILTER ABADDON_SOURCES EXCLUDE REGEX ".*notifier_gio\\.cpp$")
2023-03-01 05:34:55 +00:00
list(FILTER ABADDON_SOURCES EXCLUDE REGEX ".*notifier_null\\.cpp$")
2023-03-01 01:23:34 +00:00
2020-11-01 04:33:57 +00:00
add_executable(abaddon ${ABADDON_SOURCES})
target_include_directories(abaddon PUBLIC ${PROJECT_SOURCE_DIR}/src)
2021-07-03 01:41:05 +00:00
target_include_directories(abaddon PUBLIC ${PROJECT_BINARY_DIR})
target_include_directories(abaddon PUBLIC ${GTKMM_INCLUDE_DIRS})
target_include_directories(abaddon PUBLIC ${ZLIB_INCLUDE_DIRS})
target_include_directories(abaddon PUBLIC ${SQLite3_INCLUDE_DIRS})
target_include_directories(abaddon PUBLIC ${NLOHMANN_JSON_INCLUDE_DIRS})
2023-07-10 02:31:21 +00:00
if (ENABLE_QRCODE_LOGIN)
add_library(qrcodegen subprojects/qrcodegen/cpp/qrcodegen.hpp subprojects/qrcodegen/cpp/qrcodegen.cpp)
target_include_directories(qrcodegen PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/subprojects/qrcodegen/cpp")
target_link_libraries(abaddon qrcodegen)
2023-07-10 02:31:21 +00:00
target_include_directories(abaddon PUBLIC "subprojects/qrcodegen/cpp")
target_compile_definitions(abaddon PRIVATE WITH_QRLOGIN)
endif ()
2023-01-30 02:33:34 +00:00
target_precompile_headers(abaddon PRIVATE <gtkmm.h> src/abaddon.hpp src/util.hpp)
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
2022-04-08 18:50:11 +00:00
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_CXX_COMPILER_VERSION LESS 9))))
target_link_libraries(abaddon stdc++fs)
endif ()
2023-03-01 01:23:34 +00:00
if (NOT WIN32)
target_sources(abaddon PRIVATE src/notifications/notifier_gio.cpp)
else ()
target_sources(abaddon PRIVATE src/notifications/notifier_null.cpp)
2023-03-01 01:23:34 +00:00
endif ()
if (IXWebSocket_LIBRARIES)
2022-04-08 18:50:11 +00:00
target_link_libraries(abaddon ${IXWebSocket_LIBRARIES})
find_library(MBEDTLS_X509_LIBRARY mbedx509)
find_library(MBEDTLS_TLS_LIBRARY mbedtls)
find_library(MBEDTLS_CRYPTO_LIBRARY mbedcrypto)
if (MBEDTLS_TLS_LIBRARY)
target_link_libraries(abaddon ${MBEDTLS_TLS_LIBRARY})
endif ()
if (MBEDTLS_X509_LIBRARY)
target_link_libraries(abaddon ${MBEDTLS_X509_LIBRARY})
endif ()
if (MBEDTLS_CRYPTO_LIBRARY)
target_link_libraries(abaddon ${MBEDTLS_CRYPTO_LIBRARY})
endif ()
else ()
target_link_libraries(abaddon $<BUILD_INTERFACE:ixwebsocket>)
endif ()
find_package(Threads)
if (Threads_FOUND)
2022-04-08 18:50:11 +00:00
target_link_libraries(abaddon Threads::Threads)
endif ()
find_package(Fontconfig QUIET)
if (Fontconfig_FOUND)
target_link_libraries(abaddon Fontconfig::Fontconfig)
endif ()
find_package(spdlog REQUIRED)
target_link_libraries(abaddon spdlog::spdlog)
target_link_libraries(abaddon ${SQLite3_LIBRARIES})
target_link_libraries(abaddon ${GTKMM_LIBRARIES})
target_link_libraries(abaddon ${CURL_LIBRARIES})
2020-12-11 02:32:02 +00:00
target_link_libraries(abaddon ${ZLIB_LIBRARY})
target_link_libraries(abaddon ${NLOHMANN_JSON_LIBRARIES})
2023-04-27 01:55:12 +00:00
target_link_libraries(abaddon ${CMAKE_DL_LIBS})
2022-04-08 18:50:11 +00:00
2023-04-29 03:06:54 +00:00
include(CheckAtomic)
if (NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
target_link_libraries(abaddon atomic)
endif ()
2022-04-08 18:50:11 +00:00
if (USE_LIBHANDY)
find_package(libhandy REQUIRED)
target_include_directories(abaddon PUBLIC ${libhandy_INCLUDE_DIRS})
target_link_libraries(abaddon ${libhandy_LIBRARIES})
target_compile_definitions(abaddon PRIVATE WITH_LIBHANDY)
2022-04-08 18:50:11 +00:00
endif ()
2022-08-09 02:50:27 +00:00
if (USE_KEYCHAIN)
find_package(keychain QUIET)
if (NOT keychain_FOUND)
message("keychain was not found and will be included as a submodule")
add_subdirectory(subprojects/keychain)
target_link_libraries(abaddon keychain)
target_compile_definitions(abaddon PRIVATE WITH_KEYCHAIN)
2022-04-08 18:50:11 +00:00
endif ()
endif ()
2022-08-28 20:58:09 +00:00
set(USE_MINIAUDIO FALSE)
2022-08-28 20:58:09 +00:00
if (ENABLE_VOICE)
2022-08-31 05:51:02 +00:00
target_compile_definitions(abaddon PRIVATE WITH_VOICE)
find_package(PkgConfig)
set(USE_MINIAUDIO TRUE)
2022-08-31 05:51:02 +00:00
pkg_check_modules(Opus REQUIRED IMPORTED_TARGET opus)
target_link_libraries(abaddon PkgConfig::Opus)
pkg_check_modules(libsodium REQUIRED IMPORTED_TARGET libsodium)
target_link_libraries(abaddon PkgConfig::libsodium)
2022-08-31 20:44:30 +00:00
target_link_libraries(abaddon ${CMAKE_DL_LIBS})
2023-05-28 06:13:36 +00:00
if (ENABLE_RNNOISE)
2023-07-18 06:02:39 +00:00
target_compile_definitions(abaddon PRIVATE WITH_RNNOISE)
2023-05-28 06:13:36 +00:00
find_package(rnnoise QUIET)
if (NOT rnnoise_FOUND)
message("rnnoise was not found and will be included as a submodule")
# This is potentially really stupid
add_library(rnnoise
subprojects/rnnoise/src/arch.h
subprojects/rnnoise/src/celt_lpc.c
subprojects/rnnoise/src/celt_lpc.h
subprojects/rnnoise/src/common.h
subprojects/rnnoise/src/denoise.c
subprojects/rnnoise/src/kiss_fft.c
subprojects/rnnoise/src/kiss_fft.h
subprojects/rnnoise/src/opus_types.h
subprojects/rnnoise/src/pitch.c
subprojects/rnnoise/src/pitch.h
subprojects/rnnoise/src/rnn_data.c
subprojects/rnnoise/src/rnn_data.h
subprojects/rnnoise/src/rnn_reader.c
subprojects/rnnoise/src/rnn.c
subprojects/rnnoise/src/rnn.h
subprojects/rnnoise/src/tansig_table.h
subprojects/rnnoise/src/_kiss_fft_guts.h
subprojects/rnnoise/include/rnnoise.h)
target_include_directories(rnnoise PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/subprojects/rnnoise/include")
target_link_libraries(abaddon rnnoise)
endif ()
endif ()
2023-07-18 01:37:24 +00:00
if (APPLE)
target_link_libraries(abaddon "-framework CoreFoundation")
target_link_libraries(abaddon "-framework CoreAudio")
target_link_libraries(abaddon "-framework AudioToolbox")
endif ()
2022-08-28 20:58:09 +00:00
endif ()
if (${ENABLE_NOTIFICATION_SOUNDS})
set(USE_MINIAUDIO TRUE)
target_compile_definitions(abaddon PRIVATE ENABLE_NOTIFICATION_SOUNDS)
endif ()
2023-03-07 01:45:10 +00:00
if (USE_MINIAUDIO)
2023-07-02 02:27:57 +00:00
find_path(MINIAUDIO_INCLUDE_DIR
2023-08-26 00:36:36 +00:00
NAMES miniaudio.h
HINTS subprojects
PATH_SUFFIXES miniaudio
REQUIRED)
if (APPLE)
target_link_libraries(abaddon "-framework CoreFoundation")
target_link_libraries(abaddon "-framework CoreAudio")
target_link_libraries(abaddon "-framework AudioToolbox")
endif ()
2023-07-02 02:27:57 +00:00
target_include_directories(abaddon PUBLIC ${MINIAUDIO_INCLUDE_DIR})
2023-05-02 04:18:52 +00:00
target_compile_definitions(abaddon PRIVATE WITH_MINIAUDIO)
2023-03-07 01:45:10 +00:00
endif ()