CMakeLists.txt
3.6 KB
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
include_directories(${CMAKE_SOURCE_DIR})
set(sources
cat.cc
endpoint.cc
features.cc
file-utils.cc
online-lstm-transducer-model.cc
online-recognizer.cc
online-stream.cc
online-transducer-greedy-search-decoder.cc
online-transducer-model-config.cc
online-transducer-model.cc
online-zipformer-transducer-model.cc
onnx-utils.cc
parse-options.cc
resample.cc
symbol-table.cc
text-utils.cc
unbind.cc
wave-reader.cc
)
if(SHERPA_ONNX_ENABLE_CHECK)
list(APPEND sources log.cc)
endif()
add_library(sherpa-onnx-core ${sources})
if(ANDROID_NDK)
target_link_libraries(sherpa-onnx-core android log)
endif()
target_link_libraries(sherpa-onnx-core
onnxruntime
kaldi-native-fbank-core
)
if(SHERPA_ONNX_ENABLE_CHECK)
target_compile_definitions(sherpa-onnx-core PUBLIC SHERPA_ONNX_ENABLE_CHECK=1)
if(SHERPA_ONNX_HAVE_EXECINFO_H)
target_compile_definitions(sherpa-onnx-core PRIVATE SHERPA_ONNX_HAVE_EXECINFO_H=1)
endif()
if(SHERPA_ONNX_HAVE_CXXABI_H)
target_compile_definitions(sherpa-onnx-core PRIVATE SHERPA_ONNX_HAVE_CXXABI_H=1)
endif()
endif()
add_executable(sherpa-onnx sherpa-onnx.cc)
target_link_libraries(sherpa-onnx sherpa-onnx-core)
if(NOT WIN32)
target_link_libraries(sherpa-onnx "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib")
endif()
install(TARGETS sherpa-onnx-core DESTINATION lib)
install(TARGETS sherpa-onnx DESTINATION bin)
if(SHERPA_ONNX_HAS_ALSA)
add_executable(sherpa-onnx-alsa sherpa-onnx-alsa.cc alsa.cc)
target_link_libraries(sherpa-onnx-alsa PRIVATE sherpa-onnx-core)
if(DEFINED ENV{SHERPA_ONNX_ALSA_LIB_DIR})
target_link_libraries(sherpa-onnx-alsa PRIVATE -L$ENV{SHERPA_ONNX_ALSA_LIB_DIR} -lasound)
else()
target_link_libraries(sherpa-onnx-alsa PRIVATE asound)
endif()
install(TARGETS sherpa-onnx-alsa DESTINATION bin)
endif()
if(SHERPA_ONNX_ENABLE_PORTAUDIO)
add_executable(sherpa-onnx-microphone
sherpa-onnx-microphone.cc
microphone.cc
)
if(BUILD_SHARED_LIBS)
set(PA_LIB portaudio)
else()
set(PA_LIB portaudio_static)
endif()
target_link_libraries(sherpa-onnx-microphone PRIVATE ${PA_LIB} sherpa-onnx-core)
install(TARGETS sherpa-onnx-microphone DESTINATION bin)
endif()
if(SHERPA_ONNX_ENABLE_WEBSOCKET)
add_definitions(-DASIO_STANDALONE)
add_definitions(-D_WEBSOCKETPP_CPP11_STL_)
add_executable(sherpa-onnx-online-websocket-server
online-websocket-server-impl.cc
online-websocket-server.cc
)
target_link_libraries(sherpa-onnx-online-websocket-server sherpa-onnx-core)
add_executable(sherpa-onnx-online-websocket-client
online-websocket-client.cc
)
target_link_libraries(sherpa-onnx-online-websocket-client sherpa-onnx-core)
if(NOT WIN32)
target_link_libraries(sherpa-onnx-online-websocket-server -pthread)
target_compile_options(sherpa-onnx-online-websocket-server PRIVATE -Wno-deprecated-declarations)
target_link_libraries(sherpa-onnx-online-websocket-client -pthread)
target_compile_options(sherpa-onnx-online-websocket-client PRIVATE -Wno-deprecated-declarations)
endif()
endif()
if(SHERPA_ONNX_ENABLE_TESTS)
set(sherpa_onnx_test_srcs
cat-test.cc
unbind-test.cc
)
function(sherpa_onnx_add_test source)
get_filename_component(name ${source} NAME_WE)
set(target_name ${name})
add_executable(${target_name} "${source}")
target_link_libraries(${target_name}
PRIVATE
gtest
gtest_main
sherpa-onnx-core
)
add_test(NAME "${target_name}"
COMMAND
$<TARGET_FILE:${target_name}>
)
endfunction()
foreach(source IN LISTS sherpa_onnx_test_srcs)
sherpa_onnx_add_test(${source})
endforeach()
endif()