Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
a4d462e3
Commit
a4d462e3
authored
Feb 18, 2025
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add initial CMake file.
parent
ef662aad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
500 additions
and
0 deletions
+500
-0
CMakeLists.txt
CMakeLists.txt
+500
-0
No files found.
CMakeLists.txt
0 → 100644
View file @
a4d462e3
cmake_minimum_required
(
VERSION 3.10
)
project
(
miniaudio
VERSION 0.11
)
# Options
option
(
MINIAUDIO_BUILD_EXAMPLES
"Build miniaudio examples"
OFF
)
option
(
MINIAUDIO_BUILD_TESTS
"Build miniaudio tests"
OFF
)
option
(
MINIAUDIO_FORCE_CXX
"Use C++ compiler for C files"
OFF
)
option
(
MINIAUDIO_FORCE_C89
"Use C89 standard"
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
)
option
(
MINIAUDIO_NO_DSOUND
"Disable the DirectSound backend"
OFF
)
option
(
MINIAUDIO_NO_WINMM
"Disable the WinMM backend"
OFF
)
option
(
MINIAUDIO_NO_ALSA
"Disable the ALSA backend"
OFF
)
option
(
MINIAUDIO_NO_PULSEAUDIO
"Disable the PulseAudio backend"
OFF
)
option
(
MINIAUDIO_NO_JACK
"Disable the JACK backend"
OFF
)
option
(
MINIAUDIO_NO_COREAUDIO
"Disable the CoreAudio backend"
OFF
)
option
(
MINIAUDIO_NO_SNDIO
"Disable the sndio backend"
OFF
)
option
(
MINIAUDIO_NO_AUDIO4
"Disable the audio(4) backend"
OFF
)
option
(
MINIAUDIO_NO_OSS
"Disable the OSS backend"
OFF
)
option
(
MINIAUDIO_NO_AAUDIO
"Disable the AAudio backend"
OFF
)
option
(
MINIAUDIO_NO_OPENSL
"Disable the OpenSL|ES backend"
OFF
)
option
(
MINIAUDIO_NO_WEBAUDIO
"Disable the Web Audio backend"
OFF
)
option
(
MINIAUDIO_NO_CUSTOM
"Disable support for custom backends"
OFF
)
option
(
MINIAUDIO_NO_NULL
"Disable the null backend"
OFF
)
option
(
MINIAUDIO_ENABLE_ONLY_SPECIFIC_BACKENDS
"Only enable specific backends. Backends can be enabled with MINIAUDIO_ENABLE_[BACKEND]"
OFF
)
option
(
MINIAUDIO_ENABLE_WASAPI
"Enable the WASAPI backend"
OFF
)
option
(
MINIAUDIO_ENABLE_DSOUND
"Enable the DirectSound backend"
OFF
)
option
(
MINIAUDIO_ENABLE_WINMM
"Enable the WinMM backend"
OFF
)
option
(
MINIAUDIO_ENABLE_ALSA
"Enable the ALSA backend"
OFF
)
option
(
MINIAUDIO_ENABLE_PULSEAUDIO
"Enable the PulseAudio backend"
OFF
)
option
(
MINIAUDIO_ENABLE_JACK
"Enable the JACK backend"
OFF
)
option
(
MINIAUDIO_ENABLE_COREAUDIO
"Enable the CoreAudio backend"
OFF
)
option
(
MINIAUDIO_ENABLE_SNDIO
"Enable the sndio backend"
OFF
)
option
(
MINIAUDIO_ENABLE_AUDIO4
"Enable the audio(4) backend"
OFF
)
option
(
MINIAUDIO_ENABLE_OSS
"Enable the OSS backend"
OFF
)
option
(
MINIAUDIO_ENABLE_AAUDIO
"Enable the AAudio backend"
OFF
)
option
(
MINIAUDIO_ENABLE_OPENSL
"Enable the OpenSL|ES backend"
OFF
)
option
(
MINIAUDIO_ENABLE_WEBAUDIO
"Enable the Web Audio backend"
OFF
)
option
(
MINIAUDIO_ENABLE_CUSTOM
"Enable support for custom backends"
OFF
)
option
(
MINIAUDIO_ENABLE_NULL
"Enable the null backend"
OFF
)
option
(
MINIAUDIO_NO_DECODING
"Disable decoding APIs"
OFF
)
option
(
MINIAUDIO_NO_ENCODING
"Disable encoding APIs"
OFF
)
option
(
MINIAUDIO_NO_WAV
"Disable the built-in WAV decoder"
OFF
)
option
(
MINIAUDIO_NO_FLAC
"Disable the built-in FLAC decoder"
OFF
)
option
(
MINIAUDIO_NO_MP3
"Disable the built-in MP3 decoder"
OFF
)
option
(
MINIAUDIO_NO_DEVICEIO
"Disable audio playback and capture"
OFF
)
option
(
MINIAUDIO_NO_RESOURCE_MANAGER
"Disable the resource manager API"
OFF
)
option
(
MINIAUDIO_NO_NODE_GRAPH
"Disable the node graph API"
OFF
)
option
(
MINIAUDIO_NO_ENGINE
"Disable the high-level engine API"
OFF
)
option
(
MINIAUDIO_NO_THREADING
"Disable threading. Must be used with MINIAUDIO_NO_DEVICEIO"
OFF
)
option
(
MINIAUDIO_NO_GENERATION
"Disable generation APIs such as ma_waveform"
OFF
)
option
(
MINIAUDIO_NO_SSE2
"Disable SSE2 optimizations"
OFF
)
option
(
MINIAUDIO_NO_AVX2
"Disable AVX2 optimizations"
OFF
)
option
(
MINIAUDIO_NO_NEON
"Disable NEON optimizations"
OFF
)
option
(
MINIAUDIO_NO_RUNTIME_LINKING
"Disable runtime linking"
OFF
)
option
(
MINIAUDIO_USE_STDINT
"Use <stdint.h> for sized types"
OFF
)
option
(
MINIAUDIO_DEBUG_OUTPUT
"Enable stdout debug output"
OFF
)
# Construct compiler options.
set
(
COMPILE_OPTIONS
)
if
(
MINIAUDIO_FORCE_CXX
)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
OR CMAKE_CXX_COMPILER_ID STREQUAL
"Clang"
)
list
(
APPEND COMPILE_OPTIONS -x c++
)
elseif
(
CMAKE_CXX_COMPILER_ID STREQUAL
"MSVC"
)
list
(
APPEND COMPILE_OPTIONS /TP
)
endif
()
endif
()
if
(
MINIAUDIO_FORCE_C89
)
if
(
CMAKE_C_COMPILER_ID STREQUAL
"GNU"
OR CMAKE_C_COMPILER_ID STREQUAL
"Clang"
)
list
(
APPEND COMPILE_OPTIONS -std=c89
)
elseif
(
CMAKE_C_COMPILER_ID STREQUAL
"MSVC"
)
# MSVC does not have an option for forcing C89.
endif
()
endif
()
# Warnings
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
OR CMAKE_CXX_COMPILER_ID STREQUAL
"Clang"
)
list
(
APPEND COMPILE_OPTIONS -Wall -Wextra -Wpedantic
)
elseif
(
CMAKE_CXX_COMPILER_ID STREQUAL
"MSVC"
)
list
(
APPEND COMPILE_OPTIONS /W4
)
endif
()
# Construct compiler defines
set
(
COMPILE_DEFINES
)
if
(
MINIAUDIO_NO_WASAPI
)
list
(
APPEND COMPILE_DEFINES MA_NO_WASAPI
)
endif
()
if
(
MINIAUDIO_NO_DSOUND
)
list
(
APPEND COMPILE_DEFINES MA_NO_DSOUND
)
endif
()
if
(
MINIAUDIO_NO_WINMM
)
list
(
APPEND COMPILE_DEFINES MA_NO_WINMM
)
endif
()
if
(
MINIAUDIO_NO_ALSA
)
list
(
APPEND COMPILE_DEFINES MA_NO_ALSA
)
endif
()
if
(
MINIAUDIO_NO_PULSEAUDIO
)
list
(
APPEND COMPILE_DEFINES MA_NO_PULSEAUDIO
)
endif
()
if
(
MINIAUDIO_NO_JACK
)
list
(
APPEND COMPILE_DEFINES MA_NO_JACK
)
endif
()
if
(
MINIAUDIO_NO_COREAUDIO
)
list
(
APPEND COMPILE_DEFINES MA_NO_COREAUDIO
)
endif
()
if
(
MINIAUDIO_NO_SNDIO
)
list
(
APPEND COMPILE_DEFINES MA_NO_SNDIO
)
endif
()
if
(
MINIAUDIO_NO_AUDIO4
)
list
(
APPEND COMPILE_DEFINES MA_NO_AUDIO4
)
endif
()
if
(
MINIAUDIO_NO_OSS
)
list
(
APPEND COMPILE_DEFINES MA_NO_OSS
)
endif
()
if
(
MINIAUDIO_NO_AAUDIO
)
list
(
APPEND COMPILE_DEFINES MA_NO_AAUDIO
)
endif
()
if
(
MINIAUDIO_NO_OPENSL
)
list
(
APPEND COMPILE_DEFINES MA_NO_OPENSL
)
endif
()
if
(
MINIAUDIO_NO_WEBAUDIO
)
list
(
APPEND COMPILE_DEFINES MA_NO_WEBAUDIO
)
endif
()
if
(
MINIAUDIO_NO_CUSTOM
)
list
(
APPEND COMPILE_DEFINES MA_NO_CUSTOM
)
endif
()
if
(
MINIAUDIO_NO_NULL
)
list
(
APPEND COMPILE_DEFINES MA_NO_NULL
)
endif
()
if
(
MINIAUDIO_ENABLE_ONLY_SPECIFIC_BACKENDS
)
if
(
MINIAUDIO_ENABLE_WASAPI
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_WASAPI
)
endif
()
if
(
MINIAUDIO_ENABLE_DSOUND
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_DSOUND
)
endif
()
if
(
MINIAUDIO_ENABLE_WINMM
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_WINMM
)
endif
()
if
(
MINIAUDIO_ENABLE_ALSA
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_ALSA
)
endif
()
if
(
MINIAUDIO_ENABLE_PULSEAUDIO
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_PULSEAUDIO
)
endif
()
if
(
MINIAUDIO_ENABLE_JACK
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_JACK
)
endif
()
if
(
MINIAUDIO_ENABLE_COREAUDIO
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_COREAUDIO
)
endif
()
if
(
MINIAUDIO_ENABLE_SNDIO
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_SNDIO
)
endif
()
if
(
MINIAUDIO_ENABLE_AUDIO4
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_AUDIO4
)
endif
()
if
(
MINIAUDIO_ENABLE_OSS
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_OSS
)
endif
()
if
(
MINIAUDIO_ENABLE_AAUDIO
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_AAUDIO
)
endif
()
if
(
MINIAUDIO_ENABLE_OPENSL
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_OPENSL
)
endif
()
if
(
MINIAUDIO_ENABLE_WEBAUDIO
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_WEBAUDIO
)
endif
()
if
(
MINIAUDIO_ENABLE_CUSTOM
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_CUSTOM
)
endif
()
if
(
MINIAUDIO_ENABLE_NULL
)
list
(
APPEND COMPILE_DEFINES MA_ENABLE_NULL
)
endif
()
endif
()
if
(
MINIAUDIO_NO_DECODING
)
list
(
APPEND COMPILE_DEFINES MA_NO_DECODING
)
endif
()
if
(
MINIAUDIO_NO_ENCODING
)
list
(
APPEND COMPILE_DEFINES MA_NO_ENCODING
)
endif
()
if
(
MINIAUDIO_NO_WAV
)
list
(
APPEND COMPILE_DEFINES MA_NO_WAV
)
endif
()
if
(
MINIAUDIO_NO_FLAC
)
list
(
APPEND COMPILE_DEFINES MA_NO_FLAC
)
endif
()
if
(
MINIAUDIO_NO_MP3
)
list
(
APPEND COMPILE_DEFINES MA_NO_MP3
)
endif
()
if
(
MINIAUDIO_NO_DEVICEIO
)
list
(
APPEND COMPILE_DEFINES MA_NO_DEVICE_IO
)
endif
()
if
(
MINIAUDIO_NO_RESOURCE_MANAGER
)
list
(
APPEND COMPILE_DEFINES MA_NO_RESOURCE_MANAGER
)
endif
()
if
(
MINIAUDIO_NO_NODE_GRAPH
)
list
(
APPEND COMPILE_DEFINES MA_NO_NODE_GRAPH
)
endif
()
if
(
MINIAUDIO_NO_ENGINE
)
list
(
APPEND COMPILE_DEFINES MA_NO_ENGINE
)
endif
()
if
(
MINIAUDIO_NO_THREADING
)
list
(
APPEND COMPILE_DEFINES MA_NO_THREADING
)
endif
()
if
(
MINIAUDIO_NO_GENERATION
)
list
(
APPEND COMPILE_DEFINES MA_NO_GENERATION
)
endif
()
if
(
MINIAUDIO_NO_SSE2
)
list
(
APPEND COMPILE_DEFINES MA_NO_SSE2
)
endif
()
if
(
MINIAUDIO_NO_AVX2
)
list
(
APPEND COMPILE_DEFINES MA_NO_AVX2
)
endif
()
if
(
MINIAUDIO_NO_NEON
)
list
(
APPEND COMPILE_DEFINES MA_NO_NEON
)
endif
()
if
(
MINIAUDIO_NO_RUNTIME_LINKING
)
list
(
APPEND COMPILE_DEFINES MA_NO_RUNTIME_LINKING
)
endif
()
if
(
MINIAUDIO_USE_STDINT
)
list
(
APPEND COMPILE_DEFINES MA_USE_STDINT
)
endif
()
if
(
MINIAUDIO_DEBUG_OUTPUT
)
list
(
APPEND COMPILE_DEFINES MA_DEBUG_OUTPUT
)
endif
()
# External Libraries
if
(
NOT MINIAUDIO_NO_LIBVORBIS
)
find_library
(
LIBVORBISFILE NAMES vorbisfile
)
if
(
LIBVORBISFILE
)
message
(
STATUS
"Found libvorbisfile:
${
LIBVORBISFILE
}
"
)
set
(
HAS_LIBVORBIS TRUE
)
else
()
message
(
STATUS
"libvorbisfile not found. miniaudio_libvorbis will be excluded."
)
endif
()
endif
()
if
(
NOT MINIAUDIO_NO_LIBOPUS
)
find_library
(
LIBOPUSFILE NAMES opusfile
)
if
(
LIBOPUSFILE
)
message
(
STATUS
"Found libopusfile:
${
LIBOPUSFILE
}
"
)
# opusfile is very annoying because they do "#include <opus_multistream.h>" in opusfile.h which results
# in an error unless we explicitly add the include path to the opus include directory.
find_path
(
OPUSFILE_INCLUDE_DIR
NAMES opus/opusfile.h
DOC
"Directory containing opusfile.h"
)
if
(
OPUSFILE_INCLUDE_DIR
)
message
(
STATUS
"Found opusfile.h in
${
OPUSFILE_INCLUDE_DIR
}
"
)
set
(
HAS_LIBOPUS TRUE
)
else
()
message
(
STATUS
"Could not find opusfile.h. miniaudio_libopus will be excluded."
)
endif
()
else
()
message
(
STATUS
"libopusfile not found. miniaudio_libopus will be excluded."
)
endif
()
endif
()
find_library
(
SDL2_LIBRARY NAMES SDL2
)
if
(
SDL2_LIBRARY
)
message
(
STATUS
"Found SDL2:
${
SDL2_LIBRARY
}
"
)
set
(
HAS_SDL2 TRUE
)
else
()
message
(
STATUS
"SDL2 not found. SDL2 examples will be excluded."
)
endif
()
# SteamAudio has an annoying SDK setup. In the lib folder there is a folder for each platform. We need to specify the
# platform we're compiling for.
if
(
CMAKE_SYSTEM_PROCESSOR MATCHES
"x86_64"
)
# Assume 64-bit. Now we need to check if it's for Windows or Linux.
if
(
WIN32
)
set
(
STEAMAUDIO_ARCH windows-x64
)
else
()
set
(
STEAMAUDIO_ARCH linux-x64
)
endif
()
else
()
# Assume 32-bit. Now we need to check if it's for Windows or Linux.
if
(
WIN32
)
set
(
STEAMAUDIO_ARCH windows-x86
)
else
()
set
(
STEAMAUDIO_ARCH linux-x86
)
endif
()
endif
()
# When searching for SteamAudio, we'll support installing it in the extras/steamaudio directory.
set
(
STEAMAUDIO_FIND_LIBRARY_HINTS
)
list
(
APPEND STEAMAUDIO_FIND_LIBRARY_HINTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/extras/steamaudio/lib/
${
STEAMAUDIO_ARCH
}
)
if
(
WIN32
)
else
()
list
(
APPEND STEAMAUDIO_FIND_LIBRARY_HINTS /opt/steamaudio/lib/
${
STEAMAUDIO_ARCH
}
)
list
(
APPEND STEAMAUDIO_FIND_LIBRARY_HINTS /usr/local/steamaudio/lib/
${
STEAMAUDIO_ARCH
}
)
endif
()
set
(
STEAMAUDIO_FIND_HEADER_HINTS
)
list
(
APPEND STEAMAUDIO_FIND_HEADER_HINTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/extras/steamaudio/include
)
if
(
WIN32
)
else
()
list
(
APPEND STEAMAUDIO_FIND_HEADER_HINTS /opt/steamaudio/include
)
list
(
APPEND STEAMAUDIO_FIND_HEADER_HINTS /usr/local/steamaudio/include
)
endif
()
find_library
(
STEAMAUDIO_LIBRARY NAMES phonon HINTS
${
STEAMAUDIO_FIND_LIBRARY_HINTS
}
)
if
(
STEAMAUDIO_LIBRARY
)
message
(
STATUS
"Found SteamAudio:
${
STEAMAUDIO_LIBRARY
}
"
)
find_path
(
STEAMAUDIO_INCLUDE_DIR
NAMES phonon.h
HINTS
${
STEAMAUDIO_FIND_HEADER_HINTS
}
)
if
(
STEAMAUDIO_INCLUDE_DIR
)
message
(
STATUS
"Found phonon.h in
${
STEAMAUDIO_INCLUDE_DIR
}
"
)
set
(
HAS_STEAMAUDIO TRUE
)
else
()
message
(
STATUS
"Could not find phonon.h. miniaudio_engine_steamaudio will be excluded."
)
endif
()
else
()
message
(
STATUS
"SteamAudio not found. miniaudio_engine_steamaudio will be excluded."
)
endif
()
# Link libraries
set
(
COMMON_LINK_LIBRARIES
)
if
(
UNIX
)
list
(
APPEND COMMON_LINK_LIBRARIES dl
)
# For dlopen(), etc. Most compilers will link to this by default, but some may not.
list
(
APPEND COMMON_LINK_LIBRARIES pthread
)
# Some compilers will not link to pthread by default so list it here just in case.
list
(
APPEND COMMON_LINK_LIBRARIES m
)
# If we're compiling for 32-bit ARM we need to link to -latomic.
if
(
CMAKE_SYSTEM_PROCESSOR MATCHES
"^arm"
AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES
"aarch64"
)
list
(
APPEND COMMON_LINK_LIBRARIES atomic
)
endif
()
endif
()
# Static Libraries
add_library
(
miniaudio STATIC
miniaudio.c
miniaudio.h
)
target_compile_options
(
miniaudio PRIVATE
${
COMPILE_OPTIONS
}
)
target_compile_definitions
(
miniaudio PRIVATE
${
COMPILE_DEFINES
}
)
if
(
HAS_LIBVORBIS
)
add_library
(
miniaudio_libvorbis STATIC
extras/decoders/libvorbis/miniaudio_libvorbis.c
extras/decoders/libvorbis/miniaudio_libvorbis.h
)
target_compile_options
(
miniaudio_libvorbis PRIVATE
${
COMPILE_OPTIONS
}
)
target_compile_definitions
(
miniaudio_libvorbis PRIVATE
${
COMPILE_DEFINES
}
)
target_link_libraries
(
miniaudio_libvorbis PRIVATE
${
LIBVORBISFILE
}
)
endif
()
if
(
HAS_LIBOPUS
)
add_library
(
miniaudio_libopus STATIC
extras/decoders/libopus/miniaudio_libopus.c
extras/decoders/libopus/miniaudio_libopus.h
)
target_compile_options
(
miniaudio_libopus PRIVATE
${
COMPILE_OPTIONS
}
)
target_compile_definitions
(
miniaudio_libopus PRIVATE
${
COMPILE_DEFINES
}
)
target_include_directories
(
miniaudio_libopus PRIVATE
${
OPUSFILE_INCLUDE_DIR
}
/opus
)
target_link_libraries
(
miniaudio_libopus PRIVATE
${
LIBOPUSFILE
}
)
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.
add_library
(
miniaudio_common_options INTERFACE
)
target_compile_options
(
miniaudio_common_options INTERFACE
${
COMPILE_OPTIONS
}
)
target_link_libraries
(
miniaudio_common_options INTERFACE
${
COMMON_LINK_LIBRARIES
}
)
# Tests
#
# All tests are compiled as a single translation unit. There is no need to add miniaudio as a link library.
if
(
MINIAUDIO_BUILD_TESTS
)
enable_testing
()
set
(
TESTS_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/tests
)
function
(
add_miniaudio_test name source
)
add_executable
(
${
name
}
${
TESTS_DIR
}
/
${
source
}
)
target_link_libraries
(
${
name
}
PRIVATE miniaudio_common_options
)
endfunction
()
add_miniaudio_test
(
miniaudio_test_deviceio test_deviceio/ma_test_deviceio.c
)
add_test
(
NAME miniaudio_test_deviceio COMMAND miniaudio_test_deviceio --auto
)
# This is just to test the C++ build. Don't do add_test() for this.
add_miniaudio_test
(
miniaudio_test_cpp test_cpp/ma_test_cpp.cpp
)
add_miniaudio_test
(
miniaudio_test_automated test_automated/ma_test_automated.c
)
add_test
(
NAME miniaudio_test_automated COMMAND miniaudio_test_automated
)
add_miniaudio_test
(
miniaudio_test_filtering test_filtering/ma_test_filtering.c
)
add_test
(
NAME miniaudio_test_filtering COMMAND miniaudio_test_filtering
${
CMAKE_CURRENT_SOURCE_DIR
}
/data/16-44100-stereo.flac
)
add_miniaudio_test
(
miniaudio_test_generation test_generation/ma_test_generation.c
)
add_test
(
NAME miniaudio_test_generation COMMAND miniaudio_test_generation
)
endif
()
# Examples
#
# Like tests, all examples are compiled as a single translation unit. There is no need to add miniaudio as a link library.
if
(
MINIAUDIO_BUILD_EXAMPLES
)
set
(
EXAMPLES_DIR
${
CMAKE_CURRENT_SOURCE_DIR
}
/examples
)
function
(
add_miniaudio_example name source
)
add_executable
(
${
name
}
${
EXAMPLES_DIR
}
/
${
source
}
)
target_link_libraries
(
${
name
}
PRIVATE miniaudio_common_options
)
endfunction
()
add_miniaudio_example
(
miniaudio_custom_backend custom_backend.c
)
add_miniaudio_example
(
miniaudio_custom_decoder_engine custom_decoder_engine.c
)
if
(
HAS_LIBVORBIS
)
target_link_libraries
(
miniaudio_custom_decoder_engine PRIVATE miniaudio_libvorbis
)
else
()
target_compile_definitions
(
miniaudio_custom_decoder_engine PRIVATE MA_NO_LIBVORBIS
)
message
(
STATUS
"miniaudio_libvorbis is disabled. Vorbis support is disabled in miniaudio_custom_decoder_engine."
)
endif
()
if
(
HAS_LIBOPUS
)
target_link_libraries
(
miniaudio_custom_decoder_engine PRIVATE miniaudio_libopus
)
else
()
target_compile_definitions
(
miniaudio_custom_decoder_engine PRIVATE MA_NO_LIBOPUS
)
message
(
STATUS
"miniaudio_libopus is disabled. Opus support is disabled in miniaudio_custom_decoder_engine."
)
endif
()
add_miniaudio_example
(
miniaudio_custom_decoder custom_decoder.c
)
if
(
HAS_LIBVORBIS
)
target_link_libraries
(
miniaudio_custom_decoder PRIVATE miniaudio_libvorbis
)
else
()
target_compile_definitions
(
miniaudio_custom_decoder PRIVATE MA_NO_LIBVORBIS
)
message
(
STATUS
"miniaudio_libvorbis is disabled. Vorbis support is disabled in miniaudio_custom_decoder."
)
endif
()
if
(
HAS_LIBOPUS
)
target_link_libraries
(
miniaudio_custom_decoder PRIVATE miniaudio_libopus
)
else
()
target_compile_definitions
(
miniaudio_custom_decoder PRIVATE MA_NO_LIBOPUS
)
message
(
STATUS
"miniaudio_libopus is disabled. Opus support is disabled in miniaudio_custom_decoder."
)
endif
()
add_miniaudio_example
(
miniaudio_data_source_chaining data_source_chaining.c
)
add_miniaudio_example
(
miniaudio_duplex_effect duplex_effect.c
)
add_miniaudio_example
(
miniaudio_engine_advanced engine_advanced.c
)
add_miniaudio_example
(
miniaudio_engine_effects engine_effects.c
)
add_miniaudio_example
(
miniaudio_engine_hello_world engine_hello_world.c
)
if
(
HAS_SDL2
)
add_miniaudio_example
(
miniaudio_engine_sdl engine_sdl.c
)
target_link_libraries
(
miniaudio_engine_sdl PRIVATE
${
SDL2_LIBRARY
}
)
else
()
message
(
STATUS
"SDL2 could not be found. miniaudio_engine_sdl has been excluded."
)
endif
()
if
(
HAS_STEAMAUDIO
)
add_miniaudio_example
(
miniaudio_engine_steamaudio engine_steamaudio.c
)
target_include_directories
(
miniaudio_engine_steamaudio PRIVATE
${
STEAMAUDIO_INCLUDE_DIR
}
)
target_link_libraries
(
miniaudio_engine_steamaudio PRIVATE
${
STEAMAUDIO_LIBRARY
}
)
else
()
message
(
STATUS
"SteamAudio could not be found. miniaudio_engine_steamaudio has been excluded."
)
endif
()
add_miniaudio_example
(
miniaudio_hilo_interop hilo_interop.c
)
add_miniaudio_example
(
miniaudio_node_graph node_graph.c
)
add_miniaudio_example
(
miniaudio_resource_manager_advanced resource_manager_advanced.c
)
add_miniaudio_example
(
miniaudio_resource_manager resource_manager.c
)
add_miniaudio_example
(
miniaudio_simple_capture simple_capture.c
)
add_miniaudio_example
(
miniaudio_simple_duplex simple_duplex.c
)
add_miniaudio_example
(
miniaudio_simple_enumeration simple_enumeration.c
)
add_miniaudio_example
(
miniaudio_simple_loopback simple_loopback.c
)
add_miniaudio_example
(
miniaudio_simple_looping simple_looping.c
)
add_miniaudio_example
(
miniaudio_simple_mixing simple_mixing.c
)
add_miniaudio_example
(
miniaudio_simple_playback_sine simple_playback_sine.c
)
add_miniaudio_example
(
miniaudio_simple_playback simple_playback.c
)
add_miniaudio_example
(
miniaudio_simple_spatialization simple_spatialization.c
)
endif
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment