Skip to content

Commit

Permalink
BUILD(client): RNNoise: Support linking against the system library
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
klemensn authored and felixsinger committed Jan 18, 2022
1 parent 09ad3a8 commit 96e644a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
7 changes: 6 additions & 1 deletion docs/dev/build-instructions/cmake_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -196,7 +201,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
Expand Down
34 changes: 21 additions & 13 deletions src/mumble/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -703,23 +704,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)
Expand Down

0 comments on commit 96e644a

Please sign in to comment.