-
Notifications
You must be signed in to change notification settings - Fork 52
/
CMakeLists.txt
222 lines (183 loc) · 7.8 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
cmake_minimum_required(VERSION 3.16)
project(abaddon)
set(ABADDON_RESOURCE_DIR "/usr/share/abaddon" CACHE PATH "Fallback directory for resources on Linux")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
option(USE_LIBHANDY "Enable features that require libhandy (default)" ON)
option(ENABLE_VOICE "Enable voice suppport" ON)
option(USE_KEYCHAIN "Store the token in the keychain (default)" ON)
option(ENABLE_NOTIFICATION_SOUNDS "Enable notification sounds (default)" ON)
option(ENABLE_RNNOISE "Enable RNNoise for voice activity detection (default)" ON)
option(ENABLE_QRCODE_LOGIN "Enable QR code login (default)" ON)
find_package(nlohmann_json REQUIRED)
find_package(CURL)
find_package(ZLIB REQUIRED)
find_package(SQLite3 REQUIRED)
find_package(gtkmm REQUIRED)
set(USE_TLS TRUE)
set(USE_OPEN_SSL TRUE)
find_package(IXWebSocket QUIET)
if (NOT IXWebSocket_FOUND)
message("ixwebsocket was not found and will be included as a submodule")
add_subdirectory(subprojects/ixwebsocket)
include_directories(IXWEBSOCKET_INCLUDE_DIRS)
endif ()
if (MINGW OR WIN32)
link_libraries(ws2_32)
endif ()
if (WIN32)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
add_compile_definitions(NOMINMAX)
endif ()
configure_file(${PROJECT_SOURCE_DIR}/src/config.h.in ${PROJECT_BINARY_DIR}/config.h)
file(GLOB_RECURSE ABADDON_SOURCES
"src/*.h"
"src/*.hpp"
"src/*.cpp"
)
list(FILTER ABADDON_SOURCES EXCLUDE REGEX ".*notifier_gio\\.cpp$")
list(FILTER ABADDON_SOURCES EXCLUDE REGEX ".*notifier_fallback\\.cpp$")
add_executable(abaddon ${ABADDON_SOURCES})
target_include_directories(abaddon PUBLIC ${PROJECT_SOURCE_DIR}/src)
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})
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)
target_include_directories(abaddon PUBLIC "subprojects/qrcodegen/cpp")
target_compile_definitions(abaddon PRIVATE WITH_QRLOGIN)
endif ()
if (NOT (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
target_precompile_headers(abaddon PRIVATE <gtkmm.h> src/abaddon.hpp src/util.hpp)
endif ()
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
(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 ()
if (NOT WIN32)
target_sources(abaddon PRIVATE src/notifications/notifier_gio.cpp)
else ()
target_sources(abaddon PRIVATE src/notifications/notifier_fallback.cpp)
endif ()
if (IXWebSocket_LIBRARIES)
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)
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 ${ZLIB_LIBRARY})
target_link_libraries(abaddon ${NLOHMANN_JSON_LIBRARIES})
target_link_libraries(abaddon ${CMAKE_DL_LIBS})
target_link_libraries(abaddon CURL::libcurl)
include(CheckAtomic)
if (NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
target_link_libraries(abaddon atomic)
endif ()
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)
endif ()
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)
endif ()
endif ()
set(USE_MINIAUDIO FALSE)
if (APPLE)
target_link_libraries(abaddon "-framework CoreFoundation")
target_link_libraries(abaddon "-framework CoreAudio")
target_link_libraries(abaddon "-framework AudioToolbox")
target_link_libraries(abaddon "-framework AudioUnit")
endif ()
if (ENABLE_VOICE)
target_compile_definitions(abaddon PRIVATE WITH_VOICE)
find_package(PkgConfig)
set(USE_MINIAUDIO TRUE)
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)
target_link_libraries(abaddon ${CMAKE_DL_LIBS})
if (ENABLE_RNNOISE)
target_compile_definitions(abaddon PRIVATE WITH_RNNOISE)
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 STATIC
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)
else ()
target_link_libraries(abaddon rnnoise::rnnoise)
endif ()
endif ()
endif ()
if (${ENABLE_NOTIFICATION_SOUNDS})
set(USE_MINIAUDIO TRUE)
target_compile_definitions(abaddon PRIVATE ENABLE_NOTIFICATION_SOUNDS)
endif ()
if (USE_MINIAUDIO)
find_path(MINIAUDIO_INCLUDE_DIR
NAMES miniaudio.h
HINTS subprojects
PATH_SUFFIXES miniaudio
REQUIRED)
target_include_directories(abaddon PUBLIC ${MINIAUDIO_INCLUDE_DIR})
target_compile_definitions(abaddon PRIVATE WITH_MINIAUDIO)
endif ()
set(ABADDON_COMPILER_DEFS "" CACHE STRING "Additional compiler definitions")
foreach (COMPILER_DEF IN LISTS ABADDON_COMPILER_DEFS)
target_compile_definitions(abaddon PRIVATE "${COMPILER_DEF}")
endforeach ()