diff options
author | Klemens Nanni <klemens@posteo.de> | 2022-01-13 10:52:42 +0300 |
---|---|---|
committer | Klemens Nanni <klemens@posteo.de> | 2022-01-13 11:57:28 +0300 |
commit | d45318d64942043ffb22dc4c6a65a31596e61d78 (patch) | |
tree | 52bd5b2ab1cad916e3c93a8082f69589339741bc | |
parent | d5cb83f32d80879955febd027770efbd8e4c1ea5 (diff) |
BUILD(client): RNNoise: Support linking against the system library
OS packages (at least on Linux and BSDs) prefer prepackaged libraries to
bundled/statically linked versions where possible.
Introduce `rnnoise` (default `ON`) and make `bundled-rnnoise` default to
it's value; this retains current behaviour.
This way, `rnnoise=OFF` disables use of RNNoise completely and a simple
`bundled-rnnoise=OFF` requires the system's library.
Tested on OpenBSD 7.0-CURRENT.
-rw-r--r-- | docs/dev/build-instructions/cmake_options.md | 7 | ||||
-rw-r--r-- | src/mumble/CMakeLists.txt | 34 |
2 files changed, 27 insertions, 14 deletions
diff --git a/docs/dev/build-instructions/cmake_options.md b/docs/dev/build-instructions/cmake_options.md index c7aa36a82..18c05202d 100644 --- a/docs/dev/build-instructions/cmake_options.md +++ b/docs/dev/build-instructions/cmake_options.md @@ -39,6 +39,11 @@ Build the included version of CELT instead of looking for one on the system. Build the included version of Opus instead of looking for one on the system. (Default: ON) +### bundled-rnnoise + +Build the included version of RNNoise instead of looking for one on the system. +(Default: ${rnnoise}) + ### bundled-speex Build the included version of Speex instead of looking for one on the system. @@ -201,7 +206,7 @@ Build redacted (outdated) plugins as well ### rnnoise -Build RNNoise for machine learning noise reduction +Use RNNoise for machine learning noise reduction. (Default: ON) ### server diff --git a/src/mumble/CMakeLists.txt b/src/mumble/CMakeLists.txt index d1dd175f5..27792be6d 100644 --- a/src/mumble/CMakeLists.txt +++ b/src/mumble/CMakeLists.txt @@ -25,7 +25,8 @@ option(bundle-qt-translations "Bundle Qt's translations as well" ${static}) option(bundled-opus "Build the included version of Opus instead of looking for one on the system." ON) option(bundled-celt "Build the included version of CELT instead of looking for one on the system." ON) option(bundled-speex "Build the included version of Speex instead of looking for one on the system." ON) -option(rnnoise "Build RNNoise for machine learning noise reduction" ON) +option(rnnoise "Use RNNoise for machine learning noise reduction." ON) +option(bundled-rnnoise "Build the included version of RNNoise instead of looking for one on the system." ${rnnoise}) option(manual-plugin "Include the built-in \"manual\" positional audio plugin." ON) @@ -717,23 +718,30 @@ else() endif() if(rnnoise) - add_subdirectory("${3RDPARTY_DIR}/rnnoise-build" "${CMAKE_CURRENT_BINARY_DIR}/rnnoise") + target_compile_definitions(mumble PRIVATE "USE_RNNOISE") - # Disable all warnings that the RNNoise code may emit - disable_warnings_for_all_targets_in("${3RDPARTY_DIR}/rnnoise-build") + if(bundled-rnnoise) + add_subdirectory("${3RDPARTY_DIR}/rnnoise-build" "${CMAKE_CURRENT_BINARY_DIR}/rnnoise") - target_compile_definitions(mumble PRIVATE "USE_RNNOISE") - target_link_libraries(mumble PRIVATE rnnoise) + # Disable all warnings that the RNNoise code may emit + disable_warnings_for_all_targets_in("${3RDPARTY_DIR}/rnnoise-build") - if(WIN32) - # Shared library on Windows (e.g. ".dll") - set_target_properties(rnnoise PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + target_link_libraries(mumble PRIVATE rnnoise) + + if(WIN32) + # Shared library on Windows (e.g. ".dll") + set_target_properties(rnnoise PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + else() + # Shared library on UNIX (e.g. ".so") + set_target_properties(rnnoise PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + endif() + + install_library(rnnoise mumble_client) else() - # Shared library on UNIX (e.g. ".so") - set_target_properties(rnnoise PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - endif() + find_pkg(rnnoise REQUIRED) - install_library(rnnoise mumble_client) + target_link_libraries(mumble PRIVATE ${rnnoise_LIBRARIES}) + endif() endif() if(qtspeech) |