Improvements to the build system for extra nodes.

With this change, nodes in the extras folder can now be compiled as a
conventional library.
This commit is contained in:
David Reid
2025-02-22 14:25:45 +10:00
parent 1fbad32949
commit 9f10bc7540
16 changed files with 105 additions and 44 deletions
+26 -1
View File
@@ -9,6 +9,7 @@ option(MINIAUDIO_BUILD_EXAMPLES "Build miniaudio examples"
option(MINIAUDIO_BUILD_TESTS "Build miniaudio tests" OFF)
option(MINIAUDIO_FORCE_CXX "Force compilation as C++" OFF)
option(MINIAUDIO_FORCE_C89 "Force compilation as C89" OFF)
option(MINIAUDIO_NO_EXTRA_NODES "Do not build extra node graph nodes" OFF)
option(MINIAUDIO_NO_LIBVORBIS "Disable miniaudio_libvorbis" OFF)
option(MINIAUDIO_NO_LIBOPUS "Disable miniaudio_libopus" OFF)
option(MINIAUDIO_NO_WASAPI "Disable the WASAPI backend" OFF)
@@ -457,7 +458,6 @@ add_library(miniaudio STATIC
)
target_include_directories(miniaudio PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_options (miniaudio PRIVATE ${COMPILE_OPTIONS})
target_compile_definitions(miniaudio PRIVATE ${COMPILE_DEFINES})
@@ -505,6 +505,31 @@ if(HAS_LIBOPUS)
endif()
if (NOT MINIAUDIO_NO_EXTRA_NODES)
function(add_extra_node name)
add_library(miniaudio_${name}_node STATIC
extras/nodes/ma_${name}_node/ma_${name}_node.c
extras/nodes/ma_${name}_node/ma_${name}_node.h
)
target_include_directories(miniaudio_${name}_node PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/extras/nodes/ma_${name}_node)
target_compile_options (miniaudio_${name}_node PRIVATE ${COMPILE_OPTIONS})
target_compile_definitions(miniaudio_${name}_node PRIVATE ${COMPILE_DEFINES})
if(MINIAUDIO_BUILD_EXAMPLES)
add_executable(miniaudio_${name}_node_example extras/nodes/ma_${name}_node/ma_${name}_node_example.c)
target_link_libraries(miniaudio_${name}_node_example PRIVATE miniaudio_common_options)
endif()
endfunction()
add_extra_node(channel_combiner)
add_extra_node(channel_separator)
add_extra_node(ltrim)
add_extra_node(reverb)
add_extra_node(vocoder)
endif()
# Interface with common options to simplify the setup of tests and examples. Note that we don't pass
# in COMPILE_DEFINES here because want to allow the tests and examples to define their own defines. If
# we were to use COMPILE_DEFINES here many of the tests and examples would not compile.