forked from locaal-ai/obs-localvocal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
151 lines (121 loc) · 5.18 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
cmake_minimum_required(VERSION 3.16...3.26)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/common/bootstrap.cmake" NO_POLICY_SCOPE)
project(${_name} VERSION ${_version})
option(ENABLE_FRONTEND_API "Use obs-frontend-api for UI functionality" ON)
option(ENABLE_QT "Use Qt functionality" ON)
option(ENABLE_TESTS "Enable tests" OFF)
include(compilerconfig)
include(defaults)
include(helpers)
add_library(${CMAKE_PROJECT_NAME} MODULE)
find_package(libobs REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs)
if(ENABLE_FRONTEND_API)
find_package(obs-frontend-api REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::obs-frontend-api)
endif()
if(ENABLE_QT)
find_qt(COMPONENTS Widgets Core)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Qt::Core Qt::Widgets)
target_compile_options(
${CMAKE_PROJECT_NAME} PRIVATE $<$<C_COMPILER_ID:Clang,AppleClang>:-Wno-quoted-include-in-framework-header
-Wno-comma>)
set_target_properties(
${CMAKE_PROJECT_NAME}
PROPERTIES AUTOMOC ON
AUTOUIC ON
AUTORCC ON)
endif()
# ys todo: we should use VCPKG_ROOT instead of using hardcord folder names
# Use vcpkg toolchain file
set(CMAKE_TOOLCHAIN_FILE "c:/Users/shiny/work/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")
# Add vcpkg installed directory to CMAKE_PREFIX_PATH
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};C:/Users/shiny/work/vcpkg/installed/x64-windows")
# Find OpenSSL
find_package(OpenSSL REQUIRED)
# Include directories
include_directories(${OPENSSL_INCLUDE_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
set(USE_SYSTEM_CURL
OFF
CACHE STRING "Use system cURL")
if(USE_SYSTEM_CURL)
find_package(CURL REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE "${CURL_LIBRARIES}")
target_include_directories(${CMAKE_PROJECT_NAME} SYSTEM PUBLIC "${CURL_INCLUDE_DIRS}")
else()
include(cmake/BuildMyCurl.cmake)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE libcurl)
endif()
include(cmake/BuildWhispercpp.cmake)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Whispercpp)
include(cmake/BuildCTranslate2.cmake)
include(cmake/BuildSentencepiece.cmake)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ct2 sentencepiece)
set(USE_SYSTEM_ONNXRUNTIME
OFF
CACHE STRING "Use system ONNX Runtime")
set(DISABLE_ONNXRUNTIME_GPU
OFF
CACHE STRING "Disables GPU support of ONNX Runtime (Only valid on Linux)")
if(DISABLE_ONNXRUNTIME_GPU)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE DISABLE_ONNXRUNTIME_GPU)
endif()
if(USE_SYSTEM_ONNXRUNTIME)
if(OS_LINUX)
find_package(Onnxruntime 1.16.3 REQUIRED)
set(Onnxruntime_INCLUDE_PATH
${Onnxruntime_INCLUDE_DIR} ${Onnxruntime_INCLUDE_DIR}/onnxruntime
${Onnxruntime_INCLUDE_DIR}/onnxruntime/core/session ${Onnxruntime_INCLUDE_DIR}/onnxruntime/core/providers/cpu)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE "${Onnxruntime_LIBRARIES}")
target_include_directories(${CMAKE_PROJECT_NAME} SYSTEM PUBLIC "${Onnxruntime_INCLUDE_PATH}")
else()
message(FATAL_ERROR "System ONNX Runtime is only supported on Linux!")
endif()
else()
include(cmake/FetchOnnxruntime.cmake)
endif()
target_sources(
${CMAKE_PROJECT_NAME}
PRIVATE src/plugin-main.c
src/transcription-filter.cpp
src/transcription-filter.c
src/transcription-filter-callbacks.cpp
src/transcription-filter-utils.cpp
src/transcription-utils.cpp
src/model-utils/model-downloader.cpp
src/model-utils/model-downloader-ui.cpp
src/model-utils/model-infos.cpp
src/model-utils/model-find-utils.cpp
src/whisper-utils/whisper-processing.cpp
src/whisper-utils/whisper-utils.cpp
src/whisper-utils/whisper-model-utils.cpp
src/whisper-utils/silero-vad-onnx.cpp
src/whisper-utils/token-buffer-thread.cpp
src/translation/language_codes.cpp
src/translation/translation.cpp
src/translation/translation-utils.cpp
src/ui/filter-replace-dialog.cpp)
set_target_properties_plugin(${CMAKE_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${_name})
if(ENABLE_TESTS)
add_executable(${CMAKE_PROJECT_NAME}-tests)
include(cmake/FindLibAvObs.cmake)
target_sources(
${CMAKE_PROJECT_NAME}-tests
PRIVATE src/tests/localvocal-offline-test.cpp
src/tests/audio-file-utils.cpp
src/transcription-utils.cpp
src/model-utils/model-infos.cpp
src/model-utils/model-find-utils.cpp
src/whisper-utils/whisper-processing.cpp
src/whisper-utils/whisper-utils.cpp
src/whisper-utils/silero-vad-onnx.cpp
src/whisper-utils/token-buffer-thread.cpp
src/translation/language_codes.cpp
src/translation/translation.cpp)
find_libav(${CMAKE_PROJECT_NAME}-tests)
target_link_libraries(${CMAKE_PROJECT_NAME}-tests PRIVATE ct2 sentencepiece Whispercpp Ort OBS::libobs)
target_include_directories(${CMAKE_PROJECT_NAME}-tests PRIVATE src)
# install the tests to the release/test directory
install(TARGETS ${CMAKE_PROJECT_NAME}-tests DESTINATION test)
endif()