-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
501 lines (473 loc) · 22.5 KB
/
Copy pathCMakeLists.txt
File metadata and controls
501 lines (473 loc) · 22.5 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
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
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.26)
# Single source of truth for the project version: the root VERSION file.
# Parsed here and injected as a
# compile definition so the C ABI version strings (nemo_speech_asr_version /
# nemo_speech_tts_version) stay in sync without a hardcoded literal.
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" _nemo_speech_version_lines)
foreach(_line ${_nemo_speech_version_lines})
if(_line MATCHES
"^NEMO_SPEECH_VERSION:[ \t]*([0-9]+\\.[0-9]+\\.[0-9]+)([-+][0-9A-Za-z.-]+)?[ \t]*$")
set(NEMO_SPEECH_VERSION "${CMAKE_MATCH_1}${CMAKE_MATCH_2}")
set(NEMO_SPEECH_PROJECT_VERSION "${CMAKE_MATCH_1}")
endif()
endforeach()
if(NOT NEMO_SPEECH_VERSION OR NOT NEMO_SPEECH_PROJECT_VERSION)
message(FATAL_ERROR "could not parse NEMO_SPEECH_VERSION from ${CMAKE_CURRENT_SOURCE_DIR}/VERSION")
endif()
# Semver build metadata for the reported version, e.g. nightly.<sha> for
# nightly release builds, which then report 0.2.0+nightly.<sha>.
set(NEMO_SPEECH_VERSION_METADATA "" CACHE STRING
"Build metadata appended to the reported version (dot-separated [0-9A-Za-z-] identifiers)")
if(NEMO_SPEECH_VERSION_METADATA)
if(NOT NEMO_SPEECH_VERSION_METADATA MATCHES "^[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*$")
message(FATAL_ERROR
"NEMO_SPEECH_VERSION_METADATA must be dot-separated [0-9A-Za-z-] identifiers")
endif()
if(NEMO_SPEECH_VERSION MATCHES "\\+")
string(APPEND NEMO_SPEECH_VERSION ".${NEMO_SPEECH_VERSION_METADATA}")
else()
string(APPEND NEMO_SPEECH_VERSION "+${NEMO_SPEECH_VERSION_METADATA}")
endif()
endif()
project(nemo_speech VERSION ${NEMO_SPEECH_PROJECT_VERSION} LANGUAGES C CXX)
add_compile_definitions(NEMO_SPEECH_VERSION_STR="${NEMO_SPEECH_VERSION}")
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
if(WIN32)
# Install the Visual C++ runtime required by Windows packages, plus the
# OpenMP runtime (vcomp140.dll) that ggml's CPU threading links against
# unless GGML_OPENMP is OFF.
if(NOT DEFINED GGML_OPENMP OR GGML_OPENMP)
set(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
endif()
include(InstallRequiredSystemLibraries)
endif()
set(NEMO_SPEECH_LICENSE_INSTALL_DIR
"${CMAKE_INSTALL_DATADIR}/licenses/nemo-speech")
install(FILES LICENSE NOTICE THIRD_PARTY_NOTICES.md
DESTINATION "${NEMO_SPEECH_LICENSE_INSTALL_DIR}")
install(FILES README.md CONTRIBUTING.md
DESTINATION "${CMAKE_INSTALL_DATADIR}/doc/nemo-speech")
install(DIRECTORY docs/
DESTINATION "${CMAKE_INSTALL_DATADIR}/doc/nemo-speech/docs")
install(DIRECTORY config/
DESTINATION "${CMAKE_INSTALL_DATADIR}/nemo-speech/config")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/share/nemo-speech")
configure_file(
models/index.json
"${CMAKE_BINARY_DIR}/share/nemo-speech/model-index.json"
COPYONLY)
install(FILES models/index.json
DESTINATION "${CMAKE_INSTALL_DATADIR}/nemo-speech"
RENAME model-index.json)
# Windows: stop <windows.h> - pulled in transitively by the CUDA headers when
# GGML_CUDA=ON - from defining the min()/max() macros, which otherwise clobber
# std::min / std::max / std::numeric_limits<>::max() in the TTS/codec sources
# (C2589/C2059). Applied before add_subdirectory so every target inherits it.
if(WIN32)
add_compile_definitions(NOMINMAX)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Emit build/compile_commands.json for clangd, IDEs, and other tooling.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
if(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path;@loader_path/../${CMAKE_INSTALL_LIBDIR}")
elseif(UNIX)
set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
endif()
# Default to an optimized build. A bare `cmake ..` otherwise yields a no-O2,
# no-NDEBUG build; until now optimization only happened because the Dockerfiles
# passed -DCMAKE_BUILD_TYPE=Release. Skip for multi-config generators (Ninja
# Multi-Config, IDEs), which pick the config at build time instead.
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 MinSizeRel)
endif()
# Optional sanitizer, off by default. Applied here (before add_subdirectory) so
# the whole program - including vendored ggml - is instrumented, which
# ThreadSanitizer needs to see backend threading.
# -DNEMO_SPEECH_SANITIZE=thread (concurrent-streaming stress test)
# -DNEMO_SPEECH_SANITIZE=address,undefined (memory / UB bugs)
set(NEMO_SPEECH_SANITIZE "" CACHE STRING
"Sanitizer to enable: address | thread | undefined (comma-separated); empty = off")
if(NEMO_SPEECH_SANITIZE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(-fsanitize=${NEMO_SPEECH_SANITIZE} -fno-omit-frame-pointer -g)
add_link_options(-fsanitize=${NEMO_SPEECH_SANITIZE})
endif()
option(NEMO_SPEECH_WITH_FLASHLIGHT "Link flashlight-text + KenLM for LM decoding" OFF)
option(NEMO_SPEECH_WITH_GRPC "Deprecated alias for NEMO_SPEECH_BUILD_GRPC" OFF)
option(NEMO_SPEECH_WITH_NMT "Deprecated alias for NEMO_SPEECH_BUILD_NMT" OFF)
option(NEMO_SPEECH_WITH_NORM "Build shared Sparrowhawk/OpenFST text normalization" OFF)
option(NEMO_SPEECH_TTS_WITH_JA "Build Japanese MagpieTTS tokenizer support" OFF)
option(NEMO_SPEECH_TTS_WITH_ZH "Build Mandarin MagpieTTS tokenizer support" OFF)
option(NEMO_SPEECH_BUILD_ASR "Build automatic speech recognition" ON)
option(NEMO_SPEECH_BUILD_DIAR "Build standalone and ASR-integrated diarization" ON)
option(NEMO_SPEECH_BUILD_TTS "Build text-to-speech" ON)
option(NEMO_SPEECH_BUILD_NMT "Build text translation (links llama.cpp)" ${NEMO_SPEECH_WITH_NMT})
option(NEMO_SPEECH_BUILD_S2S "Build full-duplex Nemotron voicechat" OFF)
option(NEMO_SPEECH_BUILD_CLI "Build the unified nemo-speech CLI" ON)
option(NEMO_SPEECH_BUILD_MIC_CAPTURE "Build microphone capture in the CLI and examples" ON)
option(NEMO_SPEECH_BUILD_HTTP "Build the HTTP server and local playground" OFF)
option(NEMO_SPEECH_HTTP_TLS "Enable TLS support in the HTTP server (requires OpenSSL)" OFF)
option(NEMO_SPEECH_BUILD_GRPC "Build Riva-compatible gRPC adapters" ${NEMO_SPEECH_WITH_GRPC})
option(NEMO_SPEECH_GRPC_USE_CONFIG "Resolve protobuf and gRPC from CMake config packages" OFF)
option(NEMO_SPEECH_BUILD_TESTS "Build first-party test executables" OFF)
option(BUILD_TESTING "Build first-party test executables" ${NEMO_SPEECH_BUILD_TESTS})
option(NEMO_SPEECH_BUILD_EXAMPLES "Build public in-process API examples" OFF)
option(NEMO_SPEECH_BUILD_TOOLS "Build developer diagnostic tools" OFF)
option(GGML_VULKAN "Enable ggml Vulkan backend" OFF)
option(GGML_METAL "Enable ggml Metal backend (Apple Silicon only)" OFF)
set(NEMO_SPEECH_DEPENDENCY_PREFIX "${CMAKE_SOURCE_DIR}/.deps" CACHE PATH
"User-writable prefix containing optional project-built dependencies")
# GGML_CUDA is forwarded directly to ggml's CMake via -DGGML_CUDA=ON.
# WITH_NMT/WITH_GRPC only seed the BUILD_* defaults above; an explicit BUILD_*
# value takes precedence.
foreach(_alias NMT GRPC)
if(NEMO_SPEECH_WITH_${_alias})
message(DEPRECATION "NEMO_SPEECH_WITH_${_alias} is deprecated; use NEMO_SPEECH_BUILD_${_alias}")
endif()
endforeach()
if(NEMO_SPEECH_BUILD_S2S)
set(NEMO_SPEECH_BUILD_ASR ON CACHE BOOL "Build automatic speech recognition" FORCE)
endif()
# Reject invalid component combinations early.
if(WIN32 AND NEMO_SPEECH_WITH_NORM)
message(FATAL_ERROR
"NEMO_SPEECH_WITH_NORM is not supported on Windows; disable normalization")
endif()
if(NEMO_SPEECH_BUILD_GRPC AND
(NOT NEMO_SPEECH_BUILD_ASR OR NOT NEMO_SPEECH_BUILD_TTS))
message(FATAL_ERROR
"NEMO_SPEECH_BUILD_GRPC currently requires both ASR and TTS")
endif()
if(NEMO_SPEECH_WITH_FLASHLIGHT AND NOT NEMO_SPEECH_BUILD_ASR)
message(FATAL_ERROR "NEMO_SPEECH_WITH_FLASHLIGHT requires ASR")
endif()
if((NEMO_SPEECH_TTS_WITH_JA OR NEMO_SPEECH_TTS_WITH_ZH) AND
NOT NEMO_SPEECH_BUILD_TTS)
message(FATAL_ERROR "Optional TTS tokenizers require NEMO_SPEECH_BUILD_TTS=ON")
endif()
if(NEMO_SPEECH_HTTP_TLS AND NOT NEMO_SPEECH_BUILD_HTTP)
message(FATAL_ERROR "NEMO_SPEECH_HTTP_TLS requires NEMO_SPEECH_BUILD_HTTP=ON")
endif()
if(NEMO_SPEECH_BUILD_TESTS)
set(BUILD_TESTING ON CACHE BOOL "Build first-party test executables" FORCE)
elseif(BUILD_TESTING)
set(NEMO_SPEECH_BUILD_TESTS ON)
endif()
if(NEMO_SPEECH_BUILD_DIAR AND NOT NEMO_SPEECH_BUILD_ASR)
message(STATUS
"Diarization currently shares the ASR runtime library; building that library "
"without the transcribe CLI/API surface")
endif()
# Drop-in cuBLAS shim (native GEMM, no cuBLASLt). Release builds can substitute
# it for real cuBLAS to reduce their runtime closure.
# Disabled by default for source builds, which link the CUDA toolkit's cuBLAS.
# Portable builds enable the shim explicitly.
# It is only built when GGML_CUDA is also ON (see the target below), and is a
# no-op for Metal, Vulkan, and CPU builds.
option(NEMO_SPEECH_CUBLAS_SHIM "Build the in-tree drop-in cuBLAS shim (native GEMM, no cuBLASLt)" OFF)
# Build ggml and llama.cpp with the patches/ series applied (see patches/README.md
# and cmake/llama_cpp.cmake). OFF builds the pristine llama.cpp submodule; the code
# then uses only stock ggml operations, at some latency cost on CUDA.
option(NEMO_SPEECH_GGML_PATCHED "Apply patches/ to ggml and llama.cpp and use the patched operations" ON)
if(NEMO_SPEECH_BUILD_S2S AND NOT NEMO_SPEECH_GGML_PATCHED AND NOT NEMO_SPEECH_LLAMA_CPP_SOURCE_DIR)
# EarTTS stores its Gemma 3 attention scale in GGUF metadata that stock
# llama.cpp ignores, which would silently change the model's output.
message(FATAL_ERROR "NEMO_SPEECH_BUILD_S2S requires NEMO_SPEECH_GGML_PATCHED=ON")
endif()
set(GGML_DEPENDENCIES ggml ggml-base ggml-cpu)
if(GGML_CUDA)
list(APPEND GGML_DEPENDENCIES ggml-cuda)
# libggml-cuda.so has libcuda.so.1 (the CUDA driver) as a NEEDED entry.
# The driver is provided at runtime by NVIDIA's container toolkit and is
# absent from the devel image - only the stub at
# ${CUDAToolkit_LIBRARY_DIR}/stubs/libcuda.so exists, with no symlink to
# libcuda.so.1. ld's rpath-link search matches NEEDED entries by exact
# filename, so pointing it at the stub dir doesn't resolve libcuda.so.1.
# Resolve it via CUDA::cuda_driver instead (linked PUBLIC on runtime_ggml
# below) - the imported target points ld at the stub file directly.
find_package(CUDAToolkit REQUIRED)
# CUDA Graphs (capture + replay each cached graph's kernel-launch sequence)
# on by default. ggml-cuda gates it at runtime and disables it for graphs it
# can't capture (e.g. shapes that change between calls).
set(GGML_CUDA_GRAPHS ON CACHE BOOL "Enable ggml-cuda CUDA Graphs")
endif()
if(GGML_VULKAN)
list(APPEND GGML_DEPENDENCIES ggml-vulkan)
endif()
if(GGML_METAL)
list(APPEND GGML_DEPENDENCIES ggml-metal)
endif()
# Tiled CPU GEMM (llamafile tinyBLAS) for F16/F32/Q8_0 matmuls. Stock ggml leaves it off; without
# it CPU matmuls run one dot product per output.
set(GGML_LLAMAFILE ON CACHE BOOL "ggml: use llamafile SGEMM")
include(cmake/llama_cpp.cmake)
add_subdirectory("${NEMO_SPEECH_LLAMA_CPP_DIR}/ggml" "${CMAKE_BINARY_DIR}/ggml" EXCLUDE_FROM_ALL)
# ggml is an implementation dependency, so install only the runtime libraries
# required by our shared libraries. Its C++ headers, CMake package, pkg-config
# metadata, and tools are not part of the public NeMo-Speech.cpp SDK.
set_property(TARGET ggml PROPERTY PUBLIC_HEADER "")
install(TARGETS ggml ggml-base ggml-cpu
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(TARGET ggml-blas)
install(TARGETS ggml-blas
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(GGML_CUDA)
install(TARGETS ggml-cuda
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(GGML_VULKAN)
install(TARGETS ggml-vulkan
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(GGML_METAL)
install(TARGETS ggml-metal
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
# In-tree cuBLAS shim backed by native GEMM kernels (no cuBLASLt). ggml-cuda
# links real cuBLAS at build time. At runtime the loader resolves its cuBLAS
# dependency to this target's matching major-version library name.
if(GGML_CUDA AND NEMO_SPEECH_CUBLAS_SHIM)
enable_language(CUDA)
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 13.0)
set(NEMO_SPEECH_CUBLAS_SOVERSION 12)
else()
set(NEMO_SPEECH_CUBLAS_SOVERSION 13)
endif()
add_library(nemo_speech_cublas_shim SHARED kernels/cublas_shim.cu)
if(CMAKE_CUDA_ARCHITECTURES)
set(NEMO_SPEECH_CUBLAS_SHIM_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}")
else()
# Fallback for ad-hoc builds that do not set an architecture. compute_80 PTX is
# JIT-portable across sm_80..Blackwell, including Thor.
set(NEMO_SPEECH_CUBLAS_SHIM_ARCHITECTURES "80-virtual")
endif()
set_target_properties(nemo_speech_cublas_shim PROPERTIES
CUDA_ARCHITECTURES "${NEMO_SPEECH_CUBLAS_SHIM_ARCHITECTURES}"
CUDA_RUNTIME_LIBRARY Static
CUDA_SEPARABLE_COMPILATION ON)
if(WIN32)
# The toolkit import library records this exact DLL name. App-local
# deployment therefore substitutes the shim without changing ggml.
set_target_properties(nemo_speech_cublas_shim PROPERTIES
OUTPUT_NAME "cublas64_${NEMO_SPEECH_CUBLAS_SOVERSION}")
else()
set_target_properties(nemo_speech_cublas_shim PROPERTIES
OUTPUT_NAME cublas
SOVERSION "${NEMO_SPEECH_CUBLAS_SOVERSION}")
configure_file(
kernels/ver_cublas.map
"${CMAKE_CURRENT_BINARY_DIR}/ver_cublas.map"
@ONLY)
target_link_options(nemo_speech_cublas_shim PRIVATE
"LINKER:--version-script=${CMAKE_CURRENT_BINARY_DIR}/ver_cublas.map")
endif()
endif()
if(NEMO_SPEECH_WITH_FLASHLIGHT)
# Define only KenLM's runtime scoring libraries. flashlight-text checks
# `TARGET kenlm::kenlm` before its own find_package / FetchContent fallback.
# Keep LGPL KenLM replaceable while absorbing permissively licensed
# flashlight-text into the ASR shared library.
set(_nemo_speech_saved_build_shared "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS ON)
include(cmake/kenlm_runtime.cmake)
# flashlight-text has no LGPL replacement requirement and is intentionally
# kept private inside libnemo_speech_asr.
set(BUILD_SHARED_LIBS OFF)
set(FL_TEXT_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(FL_TEXT_BUILD_STANDALONE OFF CACHE BOOL "" FORCE)
set(FL_TEXT_BUILD_PYTHON OFF CACHE BOOL "" FORCE)
set(FL_TEXT_USE_KENLM ON CACHE BOOL "" FORCE)
set(FL_TEXT_KENLM_MAX_ORDER 6 CACHE STRING "" FORCE)
add_subdirectory(third_party/flashlight-text EXCLUDE_FROM_ALL)
set(BUILD_SHARED_LIBS "${_nemo_speech_saved_build_shared}")
endif()
# First-party warnings. Placed after the vendored subdirectories (ggml, kenlm,
# flashlight-text) so they aren't compiled under our warning set; applies to
# src/* and tests below. Not -Werror - surface issues without breaking builds.
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
# Scope to C/C++ only: on ARM64-Windows the C++ compiler is clang-cl (so
# this branch is taken) while nvcc's host compiler is cl.exe, which rejects
# -Wextra (D8021). A bare add_compile_options would reach the CUDA compile.
add_compile_options("$<$<COMPILE_LANGUAGE:C,CXX>:-Wall;-Wextra>")
endif()
# llama.cpp for the NMT decoder. It reuses the ggml target added above (its
# CMake builds its own ggml only when the target is absent), so one ggml backend
# is shared across asr/tts/nmt. Build only libllama.
if(NEMO_SPEECH_BUILD_NMT OR NEMO_SPEECH_BUILD_S2S)
set(LLAMA_BUILD_COMMON OFF CACHE BOOL "" FORCE)
set(LLAMA_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(LLAMA_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(LLAMA_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
set(LLAMA_BUILD_SERVER OFF CACHE BOOL "" FORCE)
set(LLAMA_CURL OFF CACHE BOOL "" FORCE)
add_subdirectory("${NEMO_SPEECH_LLAMA_CPP_DIR}" "${CMAKE_BINARY_DIR}/llama.cpp" EXCLUDE_FROM_ALL)
set_property(TARGET llama PROPERTY PUBLIC_HEADER "")
install(TARGETS llama
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
add_subdirectory(src/runtime/ggml)
add_subdirectory(src/common)
if(NEMO_SPEECH_BUILD_HTTP)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/cpp-httplib/httplib.h")
message(FATAL_ERROR
"cpp-httplib is required for HTTP serving; "
"run: git submodule update --init third_party/cpp-httplib")
endif()
set(HTTPLIB_REQUIRE_OPENSSL ${NEMO_SPEECH_HTTP_TLS} CACHE BOOL "" FORCE)
set(HTTPLIB_USE_OPENSSL_IF_AVAILABLE ${NEMO_SPEECH_HTTP_TLS} CACHE BOOL "" FORCE)
set(HTTPLIB_USE_ZLIB_IF_AVAILABLE OFF CACHE BOOL "" FORCE)
set(HTTPLIB_USE_BROTLI_IF_AVAILABLE OFF CACHE BOOL "" FORCE)
set(HTTPLIB_USE_ZSTD_IF_AVAILABLE OFF CACHE BOOL "" FORCE)
set(HTTPLIB_INSTALL OFF CACHE BOOL "" FORCE)
set(HTTPLIB_TEST OFF CACHE BOOL "" FORCE)
add_subdirectory(third_party/cpp-httplib EXCLUDE_FROM_ALL)
endif()
if(NEMO_SPEECH_BUILD_ASR OR NEMO_SPEECH_BUILD_DIAR)
add_subdirectory(src/asr)
endif()
if(NEMO_SPEECH_BUILD_S2S)
add_subdirectory(src/s2s)
endif()
if(NEMO_SPEECH_BUILD_TTS)
add_subdirectory(src/tts)
endif()
if(NEMO_SPEECH_BUILD_NMT)
add_subdirectory(src/nmt)
if(NEMO_SPEECH_BUILD_ASR)
add_subdirectory(src/speech)
endif()
endif()
if(NEMO_SPEECH_BUILD_ASR OR NEMO_SPEECH_BUILD_DIAR OR
NEMO_SPEECH_BUILD_TTS OR NEMO_SPEECH_BUILD_NMT OR
NEMO_SPEECH_BUILD_CLI)
add_subdirectory(src/core)
endif()
if(NEMO_SPEECH_BUILD_HTTP)
add_subdirectory(server/http)
endif()
if(NEMO_SPEECH_BUILD_GRPC)
add_subdirectory(proto)
add_subdirectory(src/services)
add_subdirectory(src/server)
endif()
if(NEMO_SPEECH_BUILD_CLI)
add_subdirectory(app)
endif()
if(NEMO_SPEECH_BUILD_EXAMPLES OR BUILD_TESTING)
add_subdirectory(examples)
endif()
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests/cpp)
endif()
if(NEMO_SPEECH_BUILD_TOOLS)
add_subdirectory(tools)
endif()
if(NEMO_SPEECH_BUILD_ASR OR NEMO_SPEECH_BUILD_DIAR)
install(FILES include/nemo_speech/asr.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nemo_speech)
endif()
if(NEMO_SPEECH_BUILD_DIAR)
install(FILES include/nemo_speech/diar.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nemo_speech)
endif()
if(NEMO_SPEECH_BUILD_NMT)
install(FILES include/nemo_speech/nmt.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nemo_speech)
endif()
if(NEMO_SPEECH_BUILD_TTS)
install(FILES include/nemo_speech/tts.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nemo_speech)
endif()
set(NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR
"${NEMO_SPEECH_LICENSE_INSTALL_DIR}/third_party")
if(DEFINED VCPKG_INSTALLED_DIR AND DEFINED VCPKG_TARGET_TRIPLET)
file(GLOB _NEMO_SPEECH_VCPKG_COPYRIGHTS LIST_DIRECTORIES false
"${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/*/copyright")
foreach(_copyright IN LISTS _NEMO_SPEECH_VCPKG_COPYRIGHTS)
get_filename_component(_share_dir "${_copyright}" DIRECTORY)
get_filename_component(_package "${_share_dir}" NAME)
install(FILES "${_copyright}"
DESTINATION "${NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR}/vcpkg/${_package}"
RENAME LICENSE)
endforeach()
endif()
install(FILES llama.cpp/LICENSE
DESTINATION "${NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR}/ggml")
if(NEMO_SPEECH_BUILD_ASR AND NEMO_SPEECH_BUILD_CLI AND NEMO_SPEECH_BUILD_MIC_CAPTURE)
install(FILES third_party/miniaudio/LICENSE
DESTINATION "${NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR}/miniaudio")
endif()
if(TARGET nemo_speech_cublas_shim)
install(TARGETS nemo_speech_cublas_shim
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(NEMO_SPEECH_BUILD_HTTP)
install(FILES third_party/cpp-httplib/LICENSE
DESTINATION "${NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR}/cpp-httplib")
endif()
if(NEMO_SPEECH_BUILD_NMT OR NEMO_SPEECH_BUILD_S2S)
install(FILES llama.cpp/LICENSE
DESTINATION "${NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR}/llama.cpp")
endif()
if(NEMO_SPEECH_BUILD_GRPC)
install(FILES proto/riva-common/LICENSE
DESTINATION "${NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR}/riva-common")
endif()
if(NEMO_SPEECH_WITH_FLASHLIGHT)
install(FILES third_party/flashlight-text/LICENSE
DESTINATION "${NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR}/flashlight-text")
install(FILES
third_party/kenlm/LICENSE
third_party/kenlm/COPYING
third_party/kenlm/COPYING.3
third_party/kenlm/COPYING.LESSER.3
DESTINATION "${NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR}/kenlm")
endif()
if(NEMO_SPEECH_TTS_WITH_JA)
install(FILES
third_party/open_jtalk/src/COPYING
DESTINATION "${NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR}/open_jtalk")
install(FILES
third_party/open_jtalk/src/mecab/COPYING
DESTINATION "${NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR}/mecab")
install(FILES
third_party/open_jtalk/src/mecab-naist-jdic/COPYING
DESTINATION "${NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR}/naist-jdic")
endif()
if(NEMO_SPEECH_TTS_WITH_ZH)
install(FILES third_party/cppjieba/LICENSE
DESTINATION "${NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR}/cppjieba")
install(FILES third_party/cppjieba/deps/limonp/LICENSE
DESTINATION "${NEMO_SPEECH_THIRD_PARTY_LICENSE_DIR}/limonp")
endif()
configure_package_config_file(
cmake/NeMoSpeechConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/NeMoSpeechConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/NeMoSpeech)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/NeMoSpeechConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMinorVersion)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/NeMoSpeechConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/NeMoSpeechConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/NeMoSpeech)