-
Notifications
You must be signed in to change notification settings - Fork 20
/
CMakeLists.txt
788 lines (680 loc) · 27.3 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
# Copyright (C) 2023-2024 Michal Kosciesza <michal@mkiol.net>
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
cmake_minimum_required(VERSION 3.5)
option(WITH_DESKTOP "enable desktop ui" OFF)
option(WITH_SFOS "enable sfos ui" OFF)
option(WITH_FLATPAK "enable flatpak build" OFF)
option(WITH_TESTS "enable tests" OFF)
option(WITH_TRACE_LOGS "enable trace logging" OFF)
option(WITH_SANITIZERS "enable asan and ubsan in debug build" ON)
option(WITH_STATIC_SANITIZERS "link asan and ubsan statically in debug build" OFF)
option(WITH_PY "enable python libraries" ${WITH_DESKTOP})
option(WITH_SYSTEMD_SERVICE "enable systemd service" ${WITH_SFOS})
option(WITH_X11_FEATURES "enable x11 features" ON)
option(DOWNLOAD_LIBSTT "download libstt binary and install shared lib" ON)
option(DOWNLOAD_VOSK "download vosk binary and install shared lib (don't use together with BUILD_VOSK)" OFF)
option(BUILD_VOSK "download sources of vosk, build and install shared lib (don't use together with DOWNLOAD_VOSK)" ON)
option(BUILD_LIBARCHIVE "download sources of libarchive, build and link statically" ON)
option(BUILD_FMT "download sources of fmt, build and link statically" ON)
option(BUILD_CATCH2 "download sources of catch2, build and link statically" ON)
option(BUILD_WHISPERCPP "download sources of whisper.cpp, build and install shared lib" ON)
option(BUILD_WHISPERCPP_CUBLAS "build also cublas version of whisper.cpp" OFF)
option(BUILD_WHISPERCPP_HIPBLAS "build also hipblas version of whisper.cpp" OFF)
option(BUILD_WHISPERCPP_CLBLAST "build also clblast version of whisper.cpp" OFF)
option(BUILD_WHISPERCPP_OPENVINO "build also open-vino version of whisper.cpp" OFF)
option(BUILD_WHISPERCPP_VULKAN "build also vulkan version of whisper.cpp" OFF)
option(BUILD_WEBRTCVAD "download sources of webrtc vad, build and link statically" ON)
option(BUILD_OPENBLAS "download sources of openblas, build and install shared lib" ON)
option(BUILD_XZ "download sources of xz lib, build and link statically" ON)
option(BUILD_RNNOISE "download sources of rnnoise-nu lib, build and link statically" ON)
option(BUILD_PYBIND11 "download sources of pybind11, build and link statically" ON)
option(BUILD_PYTHON_MODULE "make python module archive" OFF)
option(BUILD_ESPEAK "download sources of espeak-ng lib, build and link statically" ON)
option(BUILD_ESPEAK_MODULE "make espeak module archive" ON)
option(BUILD_PIPER "download sources of piper lib, build and link statically" ON)
option(BUILD_SSPLITCPP "download sources of ssplitcpp lib, build and link statically" ON)
option(BUILD_RHVOICE "download sources of rhvoice lib, build and install shared lib" ON)
option(BUILD_RHVOICE_MODULE "make rhvoice module archive" ON)
option(BUILD_BERGAMOT "download sources of bergamot-translator lib, build and install shared lib" ON)
option(BUILD_UROMAN "download sources of uroman and install uroman lib" ON) # only for x86_64
option(BUILD_RUBBERBAND "download sources of rubberband lib, build and link statically" ON)
option(BUILD_FFMPEG "download sources of ffmpeg libs, build and link statically" ON)
option(BUILD_TAGLIB "download sources of taglib, build and link statically" ON)
option(BUILD_LIBNUMBERTEXT "download sources of libnumbertext, build and link statically" ON)
option(BUILD_QHOTKEY "download sources of qhotkey lib, build and link statically" ON)
option(BUILD_APRILASR "download sources of april-asr lib, build and link statically" ON)
option(BUILD_HTML2MD "download sources of html2md lib, build and link statically" ON)
option(BUILD_MADDY "download sources of maddy lib" ON)
option(BUILD_QQC2_BREEZE_STYLE "download sources of QQC2 Breeze Style, build and install" OFF)
if(${WITH_DESKTOP} AND ${WITH_SFOS})
message(FATAL_ERROR "options WITH_DESKTOP and WITH_SFOS cannot be set together")
endif()
if(${DOWNLOAD_VOSK} AND ${BUILD_VOSK})
set(BUILD_VOSK OFF)
message(WARNING "disabling BUILD_VOSK because DOWNLOAD_VOSK is on")
endif()
if(NOT ${WITH_DESKTOP} AND NOT ${WITH_SFOS})
message(FATAL_ERROR "one of the options should be set (WITH_DESKTOP or WITH_SFOS)")
endif()
if(NOT ${WITH_PY} AND ${BUILD_UROMAN})
set(BUILD_UROMAN OFF)
message(WARNING "disabling BUILD_UROMAN because WITH_PY is off")
endif()
if(WITH_DESKTOP)
if(WITH_FLATPAK)
set(BUILD_PYTHON_MODULE OFF)
set(BUILD_QQC2_DESKTOP_STYLE OFF)
endif()
endif()
if(WITH_SFOS)
if (${WITH_PY} AND NOT ${BUILD_PYTHON_MODULE})
set(BUILD_PYTHON_MODULE ON)
message(WARNING "enabling BUILD_PYTHON_MODULE because WITH_PY is on")
endif()
if (WITH_X11_FEATURES)
set(WITH_X11_FEATURES OFF)
message(WARNING "disabling WITH_X11_FEATURES on sfos")
endif()
set(BUILD_QQC2_DESKTOP_STYLE OFF)
endif()
set(id "dsnote")
set(info_name "Speech Note")
set(info_org "net.mkiol")
set(info_domain "mkiol.net")
set(info_dbus_speech_service "net.mkiol.Speech")
set(info_dbus_speech_interface "net.mkiol.Speech")
set(info_dbus_app_service "net.mkiol.dsnote")
set(info_dbus_app_path "/net/mkiol/dsnote")
set(info_dbus_app_id ${id})
set(info_id ${id})
set(info_binary_id ${id})
set(info_translations_id ${id})
set(info_app_icon_id ${id})
if(WITH_SFOS)
set(info_org "org.mkiol")
set(info_domain "mkiol.org")
set(info_dbus_speech_service "org.mkiol.Speech")
set(info_dbus_speech_interface "org.mkiol.Speech")
set(info_dbus_app_service "org.mkiol.dsnote")
set(info_dbus_app_path "/org/mkiol/dsnote")
set(info_binary_id "harbour-dsnote")
set(info_app_icon_id "harbour-dsnote")
endif()
if(WITH_FLATPAK)
set(info_dbus_app_service "net.mkiol.SpeechNote")
set(info_dbus_app_path "/net/mkiol/SpeechNote")
set(info_dbus_app_id "SpeechNote")
set(info_app_icon_id "net.mkiol.SpeechNote")
endif()
set(info_author "Michal Kosciesza")
set(info_author_email "michal@mkiol.net")
set(info_copyright_year "2021-2024")
set(info_support_email "${id}@mkiol.net")
set(info_webpage "https://github.com/mkiol/${id}")
set(info_webpage_additional "https://gitlab.com/mkiol/${id}")
set(info_license "Mozilla Public License 2.0")
set(info_license_url "http://mozilla.org/MPL/2.0")
set(info_license_spdx "MPL-2.0")
set(info_conf_version "96")
set(info_addon_version "1.3") # if run as a flatpak pkg, the required add-on version
set(info_version_type "-beta")
set(info_translators_str "Heimen Stoffels · Bérenger Arnaud · Karry · dashinfantry · \
Åke Engelbrektson · L'Africain · Albano Battistella · Locness3 · DevSJR · Vovkiv · Niklas Halvorsen · Matjaž Jeran")
set(info_libs_str "Qt · Coqui STT · Vosk · whisper.cpp · WebRTC-VAD · libarchive · RNNoise-nu · \
{fmt} · Piper · RHVoice · ssplit-cpp · nlohmann JSON · eSpeak NG · Bergamot Translator · \
Rubber Band Library · simdjson · uroman · astrunc · FFmpeg · LAME · Vorbis · Opus · TagLib · \
libnumbertext · april-asr · html2md · maddy")
if (WITH_DESKTOP)
set(info_libs_str "${info_libs_str} · KDBusAddons")
if (WITH_X11_FEATURES)
set(info_libs_str "${info_libs_str} · QHotkey")
endif()
endif()
project(${id} VERSION 4.7.0)
set(arch_arm32 0)
set(arch_arm64 0)
set(arch_x8664 0)
if(CMAKE_SYSTEM_PROCESSOR MATCHES ".*arm.*")
message(STATUS "arm architecture detected")
set(arch_arm32 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES ".*aarch64.*")
message(STATUS "arm64 architecture detected")
set(arch_arm64 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES ".*86_64.*")
message(STATUS "x86_64 architecture detected")
set(arch_x8664 1)
else()
message(FATAL_ERROR "unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
if(WITH_PY)
if(arch_x8664)
set(info_libs_str "${info_libs_str} · Hugging Face Transformers · Coqui TTS · faster-whisper · Mimic 3 · Unikud · WhisperSpeech")
endif()
endif()
if(NOT ${arch_x8664})
if(BUILD_WHISPERCPP_CUBLAS)
set(BUILD_WHISPERCPP_CUBLAS OFF)
message(WARNING "disabling BUILD_WHISPERCPP_CUBLAS because it is supported only on x86_64")
endif()
if(BUILD_WHISPERCPP_HIPBLAS)
set(BUILD_WHISPERCPP_HIPBLAS OFF)
message(WARNING "disabling BUILD_WHISPERCPP_HIPBLAS because it is supported only on x86_64")
endif()
if(BUILD_WHISPERCPP_CLBLAST)
set(BUILD_WHISPERCPP_CLBLAST OFF)
message(WARNING "disabling BUILD_WHISPERCPP_CLBLAST because it is supported only on x86_64")
endif()
if(BUILD_WHISPERCPP_OPENVINO)
set(BUILD_WHISPERCPP_OPENVINO OFF)
message(WARNING "disabling BUILD_WHISPERCPP_OPENVINO because it is supported only on x86_64")
endif()
endif()
if(arch_arm32)
if(BUILD_WHISPERCPP_VULKAN)
message(WARNING "disabling BUILD_WHISPERCPP_VULKAN because it is not supported only on arm32")
endif()
endif()
# dirs
include(GNUInstallDirs)
set(external_dir "${PROJECT_SOURCE_DIR}/external")
set(external_include_dir "${PROJECT_BINARY_DIR}/external/include")
set(external_lib_dir "${PROJECT_BINARY_DIR}/external/lib")
set(external_share_dir "${PROJECT_BINARY_DIR}/external/share")
set(external_bin_dir "${PROJECT_BINARY_DIR}/external/bin")
set(desktop_dir "${PROJECT_SOURCE_DIR}/desktop")
set(sfos_dir "${PROJECT_SOURCE_DIR}/sfos")
set(resources_dir "${PROJECT_SOURCE_DIR}/resources")
set(flatpak_dir "${PROJECT_SOURCE_DIR}/flatpak")
set(translations_dir "${PROJECT_SOURCE_DIR}/translations")
set(tools_dir "${PROJECT_SOURCE_DIR}/tools")
set(patches_dir "${PROJECT_SOURCE_DIR}/patches")
set(tests_dir "${PROJECT_SOURCE_DIR}/tests")
set(sources_dir "${PROJECT_SOURCE_DIR}/src")
set(systemd_dir "${PROJECT_SOURCE_DIR}/systemd")
set(dbus_dir "${PROJECT_SOURCE_DIR}/dbus")
set(binary_path "${CMAKE_INSTALL_PREFIX}/bin/${info_binary_id}")
set(cmake_path "${PROJECT_SOURCE_DIR}/cmake")
set(install_dir "share/${info_binary_id}")
set(module_install_dir ${install_dir})
set(share_install_dir "${install_dir}/share")
set(lib_install_dir "${install_dir}/lib")
set(bin_install_dir "${install_dir}/bin")
set(rpath_install_dir "${CMAKE_INSTALL_PREFIX}/${lib_install_dir}")
set(translations_resource_file "${CMAKE_BINARY_DIR}/translations.qrc")
set(xz_path "xz")
if(WITH_FLATPAK)
set(rpath_install_dir "${CMAKE_INSTALL_PREFIX}/lib")
elseif(BUILD_XZ)
set(xz_path "${external_bin_dir}/xz")
endif()
set(deps "") # dependencies of dsnote_lib and dsnote
set(deps_libs "") # libs to link to dsnote_lib and dsnote
# global config
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_SKIP_RPATH ON)
# includes
set(includes ${sources_dir} ${PROJECT_BINARY_DIR} ${external_include_dir})
# dsnote_lib
set(dsnote_lib_sources
${sources_dir}/audio_source.h
${sources_dir}/dbus_speech_adaptor.cpp
${sources_dir}/dbus_speech_adaptor.h
${sources_dir}/dbus_speech_inf.cpp
${sources_dir}/dbus_speech_inf.h
${sources_dir}/dbus_application_adaptor.cpp
${sources_dir}/dbus_application_adaptor.h
${sources_dir}/dbus_notifications_inf.cpp
${sources_dir}/dbus_notifications_inf.h
${sources_dir}/dirmodel.cpp
${sources_dir}/dirmodel.h
${sources_dir}/dsnote_app.cpp
${sources_dir}/dsnote_app.h
${sources_dir}/file_source.cpp
${sources_dir}/file_source.h
${sources_dir}/itemmodel.cpp
${sources_dir}/itemmodel.h
${sources_dir}/langs_list_model.cpp
${sources_dir}/langs_list_model.h
${sources_dir}/listmodel.cpp
${sources_dir}/listmodel.h
${sources_dir}/mic_source.cpp
${sources_dir}/mic_source.h
${sources_dir}/models_list_model.cpp
${sources_dir}/models_list_model.h
${sources_dir}/models_manager.cpp
${sources_dir}/models_manager.h
${sources_dir}/settings.cpp
${sources_dir}/settings.h
${sources_dir}/singleton.h
${sources_dir}/speech_config.cpp
${sources_dir}/speech_config.h
${sources_dir}/speech_service.cpp
${sources_dir}/speech_service.h
${sources_dir}/logger.cpp
${sources_dir}/logger.hpp
${sources_dir}/qtlogger.cpp
${sources_dir}/qtlogger.hpp
${sources_dir}/stt_engine.cpp
${sources_dir}/stt_engine.hpp
${sources_dir}/ds_engine.cpp
${sources_dir}/ds_engine.hpp
${sources_dir}/whisper_engine.cpp
${sources_dir}/whisper_engine.hpp
${sources_dir}/vosk_engine.cpp
${sources_dir}/vosk_engine.hpp
${sources_dir}/vad.cpp
${sources_dir}/vad.hpp
${sources_dir}/cpu_tools.cpp
${sources_dir}/cpu_tools.hpp
${sources_dir}/comp_tools.cpp
${sources_dir}/comp_tools.hpp
${sources_dir}/checksum_tools.cpp
${sources_dir}/checksum_tools.hpp
${sources_dir}/denoiser.hpp
${sources_dir}/denoiser.cpp
${sources_dir}/punctuator.hpp
${sources_dir}/punctuator.cpp
${sources_dir}/py_tools.hpp
${sources_dir}/py_tools.cpp
${sources_dir}/module_tools.hpp
${sources_dir}/module_tools.cpp
${sources_dir}/tts_engine.hpp
${sources_dir}/tts_engine.cpp
${sources_dir}/piper_engine.hpp
${sources_dir}/piper_engine.cpp
${sources_dir}/coqui_engine.hpp
${sources_dir}/coqui_engine.cpp
${sources_dir}/espeak_engine.hpp
${sources_dir}/espeak_engine.cpp
${sources_dir}/rhvoice_engine.hpp
${sources_dir}/rhvoice_engine.cpp
${sources_dir}/nlohmann/json.hpp
${sources_dir}/simdjson.h
${sources_dir}/simdjson.cpp
${sources_dir}/py_executor.hpp
${sources_dir}/py_executor.cpp
${sources_dir}/text_tools.hpp
${sources_dir}/text_tools.cpp
${sources_dir}/mnt_engine.hpp
${sources_dir}/mnt_engine.cpp
${sources_dir}/gpu_tools.hpp
${sources_dir}/gpu_tools.cpp
${sources_dir}/astrunc/astrunc.h
${sources_dir}/media_compressor.hpp
${sources_dir}/media_compressor.cpp
${sources_dir}/mtag_tools.hpp
${sources_dir}/mtag_tools.cpp
${sources_dir}/app_server.hpp
${sources_dir}/app_server.cpp
${sources_dir}/fasterwhisper_engine.hpp
${sources_dir}/fasterwhisper_engine.cpp
${sources_dir}/mimic3_engine.hpp
${sources_dir}/mimic3_engine.cpp
${sources_dir}/april_engine.hpp
${sources_dir}/april_engine.cpp
${sources_dir}/avlogger.hpp
${sources_dir}/avlogger.cpp
${sources_dir}/downloader.hpp
${sources_dir}/downloader.cpp
${sources_dir}/recorder.hpp
${sources_dir}/recorder.cpp
${sources_dir}/media_converter.hpp
${sources_dir}/media_converter.cpp
${sources_dir}/text_repair_engine.hpp
${sources_dir}/text_repair_engine.cpp
${sources_dir}/whisperspeech_engine.hpp
${sources_dir}/whisperspeech_engine.cpp
${sources_dir}/audio_device_manager.cpp
${sources_dir}/audio_device_manager.hpp
)
if(WITH_DESKTOP)
list(APPEND dsnote_lib_sources
${sources_dir}/tray_icon.hpp
${sources_dir}/tray_icon.cpp)
endif()
if(WITH_X11_FEATURES)
list(APPEND dsnote_lib_sources
${sources_dir}/fake_keyboard.hpp
${sources_dir}/fake_keyboard.cpp)
endif()
configure_file(config.h.in config.h)
add_library(dsnote_lib STATIC ${dsnote_lib_sources})
# resources
set(resources "")
list(APPEND resources
"${desktop_dir}/resources.qrc"
${translations_resource_file})
# executable
add_executable(${info_binary_id} ${resources} "${sources_dir}/main.cpp")
set_property(TARGET ${info_binary_id} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
set_property(TARGET ${info_binary_id} PROPERTY AUTORCC TRUE)
target_link_libraries(${info_binary_id} dsnote_lib)
add_custom_command(TARGET ${info_binary_id} POST_BUILD
COMMAND $<$<CONFIG:Release>:${CMAKE_STRIP}>
ARGS --strip-all $<TARGET_FILE:${info_binary_id}>
)
# tests
if(WITH_TESTS)
include(${cmake_path}/tests.cmake)
endif()
# flags and definitions
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo")
endif ()
add_library(compiler_flags INTERFACE)
target_compile_features(compiler_flags INTERFACE cxx_std_17)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(WITH_SANITIZERS)
target_compile_options(compiler_flags INTERFACE
"-pie;-Wall;-Wextra;-Wpedantic;-O1;-g3;-fsanitize=address,undefined")
if(WITH_STATIC_SANITIZERS)
target_link_options(compiler_flags INTERFACE
"-pie;-static-libasan;-static-libubsan;-fsanitize=address,undefined")
else()
target_link_options(compiler_flags INTERFACE "-pie;-fsanitize=address,undefined")
endif()
else()
target_compile_options(compiler_flags INTERFACE
"-pie;-Wall;-Wextra;-Wpedantic;-O1;-g3")
target_link_options(compiler_flags INTERFACE "-pie")
endif()
else()
target_compile_options(compiler_flags INTERFACE "-pie;-Wall;-Wextra;-Wpedantic;-Wno-attributes;-O3;-g")
target_link_options(compiler_flags INTERFACE "-pie;-flto;-fno-fat-lto-objects")
endif()
set(link_opts "-Wl,--disable-new-dtags;-Wl,-pie;-Wl,-rpath,${rpath_install_dir}")
if(NOT ${WITH_SFOS})
set(link_opts "${link_opts};-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib")
endif()
target_link_options(compiler_flags INTERFACE ${link_opts})
target_compile_definitions(compiler_flags INTERFACE "$<$<BOOL:${WITH_TRACE_LOGS}>:USE_TRACE_LOGS>")
target_compile_definitions(compiler_flags INTERFACE "$<$<BOOL:${WITH_SFOS}>:USE_SFOS>")
target_compile_definitions(compiler_flags INTERFACE "$<$<BOOL:${WITH_DESKTOP}>:USE_DESKTOP>")
target_compile_definitions(compiler_flags INTERFACE "$<$<BOOL:${WITH_PY}>:USE_PY>")
target_compile_definitions(compiler_flags INTERFACE "$<$<BOOL:${WITH_FLATPAK}>:USE_FLATPAK>")
target_compile_definitions(compiler_flags INTERFACE "$<$<BOOL:${WITH_X11_FEATURES}>:USE_X11_FEATURES>")
target_compile_definitions(compiler_flags INTERFACE "$<$<BOOL:${BUILD_PYTHON_MODULE}>:USE_PYTHON_MODULE>")
target_compile_definitions(compiler_flags INTERFACE "$<$<CONFIG:Debug>:DEBUG>")
target_compile_definitions(compiler_flags INTERFACE "$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>")
target_compile_definitions(compiler_flags INTERFACE "$<$<BOOL:${arch_x8664}>:ARCH_X86_64>")
target_compile_definitions(compiler_flags INTERFACE "$<$<BOOL:${arch_arm32}>:ARCH_ARM_32>")
target_compile_definitions(compiler_flags INTERFACE "$<$<BOOL:${arch_arm64}>:ARCH_ARM_64>")
target_compile_definitions(compiler_flags INTERFACE "INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
# translations
include(${cmake_path}/translations.cmake)
# dependencies
list(APPEND deps_libs
compiler_flags
pthread
${CMAKE_DL_LIBS})
set(deps_dirs "")
include(FindPkgConfig)
include(ExternalProject)
unset(meson_bin CACHE)
find_program(meson_bin meson)
unset(autoconf_bin CACHE)
find_program(autoconf_bin autoconf)
unset(automake_bin CACHE)
find_program(automake_bin automake)
unset(libtool_bin CACHE)
find_program(libtool_bin libtool)
pkg_search_module(zlib REQUIRED zlib)
list(APPEND deps_libs ${zlib_LIBRARIES})
list(APPEND includes ${zlib_INCLUDE_DIRS})
pkg_search_module(pulse REQUIRED libpulse)
list(APPEND deps_libs ${pulse_LIBRARIES})
list(APPEND includes ${pulse_INCLUDE_DIRS})
find_package(Qt5 COMPONENTS Core Network Multimedia Qml Xml Sql Gui Quick DBus LinguistTools REQUIRED)
list(APPEND deps_libs Qt5::Core Qt5::Network Qt5::Multimedia Qt5::Gui Qt5::Quick Qt5::DBus Qt5::Xml)
if(WITH_DESKTOP)
find_package(Qt5 COMPONENTS QuickControls2 Widgets REQUIRED)
list(APPEND deps_libs Qt5::QuickControls2 Qt5::Widgets)
if(WITH_X11_FEATURES)
find_package(X11 REQUIRED)
list(APPEND deps_libs X11)
find_package(Qt5 COMPONENTS X11Extras REQUIRED)
list(APPEND deps_libs Qt5::X11Extras)
pkg_search_module(xkbcommon REQUIRED xkbcommon)
list(APPEND deps_libs ${xkbcommon_LIBRARIES})
list(APPEND includes ${xkbcommon_INCLUDE_DIRS})
pkg_search_module(xkbcommonx11 REQUIRED xkbcommon-x11)
list(APPEND deps_libs ${xkbcommonx11_LIBRARIES})
list(APPEND includes ${xkbcommonx11_INCLUDE_DIRS})
if(BUILD_QHOTKEY)
include(${cmake_path}/qhotkey.cmake)
else()
find_library(qhotkey_path qhotkey REQUIRED)
list(APPEND deps_libs ${qhotkey_path})
endif()
endif()
include(${cmake_path}/kdbusservice.cmake)
endif()
if(BUILD_PYTHON_MODULE)
include(${cmake_path}/python_module.cmake)
endif()
if(BUILD_RNNOISE)
include(${cmake_path}/rnnoise.cmake)
else()
find_library(rnnoise_path rnnoise-nu REQUIRED)
list(APPEND deps_libs ${rnnoise_path})
endif()
if(BUILD_LIBARCHIVE)
include(${cmake_path}/libarchive.cmake)
else()
pkg_search_module(libarchive REQUIRED libarchive)
list(APPEND deps_libs ${libarchive_LIBRARIES})
list(APPEND includes ${libarchive_INCLUDE_DIRS})
endif()
if(DOWNLOAD_LIBSTT)
include(${cmake_path}/libstt.cmake)
endif()
if(${BUILD_VOSK} OR ${DOWNLOAD_VOSK})
include(${cmake_path}/vosk.cmake)
endif()
if(BUILD_FMT)
include(${cmake_path}/fmt.cmake)
else()
pkg_search_module(fmt REQUIRED fmt)
list(APPEND deps_libs ${fmt_LIBRARIES})
list(APPEND includes ${fmt_INCLUDE_DIRS})
endif()
if(BUILD_WHISPERCPP)
include(${cmake_path}/whispercpp.cmake)
endif()
if(BUILD_WEBRTCVAD)
include(${cmake_path}/webrtcvad.cmake)
else()
find_library(webrtcvad_path vad REQUIRED)
list(APPEND deps_libs ${webrtcvad_path})
endif()
if(BUILD_XZ)
include(${cmake_path}/xz.cmake)
else()
pkg_search_module(xz REQUIRED liblzma>=5.4.1)
list(APPEND deps_libs ${xz_LIBRARIES})
list(APPEND includes ${xz_INCLUDE_DIRS})
endif()
if(BUILD_RHVOICE)
include(${cmake_path}/rhvoice.cmake)
endif()
if(BUILD_RHVOICE_MODULE)
include(${cmake_path}/rhvoice_module.cmake)
endif()
if(BUILD_PIPER OR BUILD_ESPEAK)
include(${cmake_path}/espeak.cmake)
else()
pkg_search_module(espeak REQUIRED espeak-ng)
list(APPEND deps_libs ${espeak_LIBRARIES})
list(APPEND includes ${espeak_INCLUDE_DIRS})
endif()
if(BUILD_ESPEAK_MODULE)
include(${cmake_path}/espeak_module.cmake)
endif()
if(BUILD_PIPER)
include(${cmake_path}/piper.cmake)
else()
pkg_search_module(spdlog_path REQUIRED spdlog)
list(APPEND deps_libs ${spdlog_path_LIBRARIES})
list(APPEND includes ${spdlog_path_INCLUDE_DIRS})
find_library(piper_path piper_api REQUIRED)
find_library(piperphonemize_path piper_phonemize REQUIRED)
find_library(onnxruntime_path onnxruntime REQUIRED)
list(APPEND deps_libs ${piper_path} ${piperphonemize_path} ${onnxruntime_path})
endif()
if(BUILD_SSPLITCPP)
include(${cmake_path}/ssplitcpp.cmake)
else()
find_library(ssplitcpp_path ssplit REQUIRED)
find_library(pcre2_path pcre2-8 REQUIRED)
find_library(pcre2posix_path pcre2-posix REQUIRED)
list(APPEND deps_libs ${ssplitcpp_path} ${pcre2_path} ${pcre2posix_path})
endif()
find_package(Python COMPONENTS Development REQUIRED)
list(APPEND deps_dirs ${Python_LIBRARY_DIRS})
list(APPEND deps_libs ${Python_LIBRARIES})
list(APPEND includes ${Python_INCLUDE_DIRS})
if(BUILD_PYBIND11)
include(${cmake_path}/pybind11.cmake)
else()
pkg_search_module(pybind11 REQUIRED pybind11)
list(APPEND deps_libs ${pybind11_LIBRARIES})
list(APPEND includes ${pybind11_INCLUDE_DIRS})
endif()
if(BUILD_BERGAMOT)
include(${cmake_path}/bergamot.cmake)
endif()
if(BUILD_OPENBLAS)
include(${cmake_path}/openblas.cmake)
else()
pkg_search_module(openblas REQUIRED openblas)
endif()
if(BUILD_APRILASR)
include(${cmake_path}/aprilasr.cmake)
else()
pkg_search_module(aprilasr REQUIRED april-asr)
list(APPEND deps_libs ${aprilasr_LIBRARIES})
list(APPEND includes ${aprilasr_INCLUDE_DIRS})
endif()
if(arch_x8664)
if(BUILD_UROMAN)
include(${cmake_path}/uroman.cmake)
endif()
endif(arch_x8664)
if(BUILD_RUBBERBAND)
include(${cmake_path}/rubberband.cmake)
else()
pkg_search_module(rubberband REQUIRED rubberband)
list(APPEND deps_libs ${rubberband_LIBRARIES})
list(APPEND includes ${rubberband_INCLUDE_DIRS})
endif()
if(BUILD_FFMPEG)
include(${cmake_path}/ffmpeg.cmake)
else()
find_library(lame_path mp3lame)
list(APPEND deps_libs ${lame_path})
pkg_search_module(ogg REQUIRED ogg)
list(APPEND deps_libs ${ogg_LIBRARIES})
list(APPEND includes ${ogg_INCLUDE_DIRS})
pkg_search_module(vorbis REQUIRED vorbis)
list(APPEND deps_libs ${vorbis_LIBRARIES})
list(APPEND includes ${vorbis_INCLUDE_DIRS})
pkg_search_module(vorbisenc REQUIRED vorbisenc)
list(APPEND deps_libs ${vorbisenc_LIBRARIES})
list(APPEND includes ${vorbisenc_INCLUDE_DIRS})
pkg_search_module(ffmpeg_avutil REQUIRED libavutil>=57.17.100)
pkg_search_module(ffmpeg_avcodec REQUIRED libavcodec>=59.18.100)
pkg_search_module(ffmpeg_avformat REQUIRED libavformat>=59.16.100)
pkg_search_module(ffmpeg_avdevice REQUIRED libavdevice>=59.7.100)
pkg_search_module(ffmpeg_avfilter REQUIRED libavfilter>=8.44.100)
pkg_search_module(ffmpeg_swresample REQUIRED libswresample>=4.3.100)
pkg_search_module(ffmpeg_swscale REQUIRED libswscale>=6.7.100)
string(REGEX REPLACE "^([0-9]+).*$" "\\1" ffmpeg_ver ${ffmpeg_avformat_VERSION})
message(STATUS "found ffmpeg version: ${ffmpeg_ver}")
list(APPEND deps_libs
${ffmpeg_avdevice_LIBRARIES}
${ffmpeg_avfilter_LIBRARIES}
${ffmpeg_avformat_LIBRARIES}
${ffmpeg_avcodec_LIBRARIES}
${ffmpeg_swresample_LIBRARIES}
${ffmpeg_swscale_LIBRARIES}
${ffmpeg_avutil_LIBRARIES})
list(APPEND includes
${ffmpeg_avutil_INCLUDE_DIRS}
${ffmpeg_avcodec_INCLUDE_DIRS}
${ffmpeg_avformat_INCLUDE_DIRS}
${ffmpeg_avdevice_INCLUDE_DIRS}
${ffmpeg_avfilter_INCLUDE_DIRS}
${ffmpeg_swresample_INCLUDE_DIRS}
${ffmpeg_swscale_INCLUDE_DIRS})
endif()
if(BUILD_TAGLIB)
include(${cmake_path}/taglib.cmake)
else()
pkg_search_module(taglib REQUIRED taglib)
list(APPEND deps_libs ${taglib_LIBRARIES})
list(APPEND includes ${taglib_INCLUDE_DIRS})
endif()
if(BUILD_LIBNUMBERTEXT)
include(${cmake_path}/libnumbertext.cmake)
else()
pkg_search_module(libnumbertext REQUIRED libnumbertext)
list(APPEND deps_libs ${libnumbertext_LIBRARIES})
list(APPEND includes ${libnumbertext_INCLUDE_DIRS})
endif()
if(BUILD_HTML2MD)
include(${cmake_path}/html2md.cmake)
else()
pkg_search_module(html2md REQUIRED html2md)
list(APPEND deps_libs ${html2md_LIBRARIES})
list(APPEND includes ${html2md_INCLUDE_DIRS})
endif()
if(BUILD_MADDY)
include(${cmake_path}/maddy.cmake)
endif()
if(WITH_SFOS)
pkg_search_module(sailfish REQUIRED sailfishapp)
list(APPEND deps_libs ${sailfish_LIBRARIES})
list(APPEND includes ${sailfish_INCLUDE_DIRS})
pkg_search_module(mlite5 REQUIRED mlite5)
list(APPEND deps_libs ${mlite5_LIBRARIES})
list(APPEND includes ${mlite5_INCLUDE_DIRS})
endif()
if(BUILD_QQC2_BREEZE_STYLE)
include(${cmake_path}/qqc2-breeze-style.cmake)
endif()
target_include_directories(${info_binary_id} PRIVATE ${includes})
target_link_libraries(${info_binary_id} ${deps_libs})
if(deps)
add_dependencies(${info_binary_id} ${deps})
endif()
target_include_directories(dsnote_lib PRIVATE ${includes})
target_link_libraries(dsnote_lib ${deps_libs})
target_link_directories(dsnote_lib PRIVATE ${deps_dirs})
if(deps)
add_dependencies(dsnote_lib ${deps})
endif()
if(WITH_TESTS)
target_include_directories(tests PRIVATE ${includes})
target_link_libraries(tests ${deps_libs})
if(deps)
add_dependencies(tests ${deps})
endif()
endif()
# install
if(WITH_SFOS)
include(${cmake_path}/install_sfos.cmake)
endif()
if(WITH_DESKTOP)
include(${cmake_path}/install_desktop.cmake)
endif()
# misc
if(WITH_SFOS)
file(WRITE "${CMAKE_BINARY_DIR}/QtCreatorDeployment.txt"
"${CMAKE_INSTALL_PREFIX}\n${CMAKE_BINARY_DIR}/${info_binary_id}:bin\n")
endif()