| 1 |
# TODO |
| 2 |
# - backend selection via command line, rather than simply detecting headers. |
| 3 |
|
| 4 |
cmake_minimum_required(VERSION 3.14 FATAL_ERROR) |
| 5 |
project(cubeb |
| 6 |
VERSION 0.0.0) |
| 7 |
|
| 8 |
option(BUILD_SHARED_LIBS "Build shared libraries" OFF) |
| 9 |
option(BUILD_TESTS "Build tests" ON) |
| 10 |
option(BUILD_RUST_LIBS "Build rust backends" OFF) |
| 11 |
option(BUILD_TOOLS "Build tools" ON) |
| 12 |
option(BUNDLE_SPEEX "Bundle the speex library" OFF) |
| 13 |
option(LAZY_LOAD_LIBS "Lazily load shared libraries" ON) |
| 14 |
option(USE_SANITIZERS "Use sanitizers" ON) |
| 15 |
|
| 16 |
if(NOT CMAKE_BUILD_TYPE) |
| 17 |
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING |
| 18 |
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) |
| 19 |
endif() |
| 20 |
|
| 21 |
set(CMAKE_C_STANDARD 99) |
| 22 |
set(CMAKE_CXX_STANDARD 17) |
| 23 |
set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 24 |
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 25 |
|
| 26 |
if(USE_SANITIZERS) |
| 27 |
if(NOT COMMAND add_sanitizers) |
| 28 |
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake") |
| 29 |
find_package(Sanitizers) |
| 30 |
if(NOT COMMAND add_sanitizers) |
| 31 |
message(FATAL_ERROR "Could not find sanitizers-cmake: run\n\tgit submodule update --init --recursive\nin base git checkout") |
| 32 |
endif() |
| 33 |
endif() |
| 34 |
else() |
| 35 |
macro(add_sanitizers UNUSED) |
| 36 |
endmacro() |
| 37 |
endif() |
| 38 |
|
| 39 |
if(BUILD_TESTS) |
| 40 |
find_package(GTest QUIET) |
| 41 |
if(TARGET GTest::Main) |
| 42 |
add_library(gtest_main ALIAS GTest::Main) |
| 43 |
endif() |
| 44 |
if(NOT TARGET gtest_main) |
| 45 |
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/googletest/CMakeLists.txt") |
| 46 |
message(FATAL_ERROR "Could not find googletest: run\n\tgit submodule update --init --recursive\nin base git checkout") |
| 47 |
endif() |
| 48 |
add_definitions(-DGTEST_HAS_TR1_TUPLE=0 -DGTEST_HAS_RTTI=0) |
| 49 |
set(gtest_force_shared_crt ON CACHE BOOL "") |
| 50 |
add_subdirectory(googletest) |
| 51 |
endif() |
| 52 |
endif() |
| 53 |
|
| 54 |
if (BUILD_RUST_LIBS) |
| 55 |
if(EXISTS "${PROJECT_SOURCE_DIR}/src/cubeb-pulse-rs") |
| 56 |
set(USE_PULSE_RUST 1) |
| 57 |
endif() |
| 58 |
if(EXISTS "${PROJECT_SOURCE_DIR}/src/cubeb-coreaudio-rs") |
| 59 |
set(USE_AUDIOUNIT_RUST 1) |
| 60 |
endif() |
| 61 |
endif() |
| 62 |
|
| 63 |
# On OS/2, visibility attribute is not supported. |
| 64 |
if(NOT OS2) |
| 65 |
set(CMAKE_C_VISIBILITY_PRESET hidden) |
| 66 |
set(CMAKE_CXX_VISIBILITY_PRESET hidden) |
| 67 |
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) |
| 68 |
endif() |
| 69 |
|
| 70 |
set(CMAKE_CXX_WARNING_LEVEL 4) |
| 71 |
if(NOT MSVC) |
| 72 |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter") |
| 73 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -fno-exceptions -fno-rtti") |
| 74 |
else() |
| 75 |
string(REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # Disable RTTI |
| 76 |
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # Disable Exceptions |
| 77 |
endif() |
| 78 |
|
| 79 |
add_library(cubeb |
| 80 |
src/cubeb.c |
| 81 |
src/cubeb_audio_dump.cpp |
| 82 |
src/cubeb_mixer.cpp |
| 83 |
src/cubeb_resampler.cpp |
| 84 |
src/cubeb_log.cpp |
| 85 |
src/cubeb_strings.c |
| 86 |
src/cubeb_utils.cpp |
| 87 |
) |
| 88 |
target_include_directories(cubeb |
| 89 |
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> |
| 90 |
) |
| 91 |
set_target_properties(cubeb PROPERTIES |
| 92 |
VERSION ${cubeb_VERSION} |
| 93 |
SOVERSION ${cubeb_VERSION_MAJOR} |
| 94 |
) |
| 95 |
|
| 96 |
add_sanitizers(cubeb) |
| 97 |
|
| 98 |
include(GenerateExportHeader) |
| 99 |
generate_export_header(cubeb EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/exports/cubeb_export.h) |
| 100 |
target_include_directories(cubeb |
| 101 |
PUBLIC $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/exports> |
| 102 |
) |
| 103 |
|
| 104 |
include(GNUInstallDirs) |
| 105 |
|
| 106 |
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/${PROJECT_NAME} TYPE INCLUDE) |
| 107 |
install(DIRECTORY ${CMAKE_BINARY_DIR}/exports/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) |
| 108 |
|
| 109 |
include(CMakePackageConfigHelpers) |
| 110 |
write_basic_package_version_file( |
| 111 |
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" |
| 112 |
COMPATIBILITY SameMajorVersion |
| 113 |
) |
| 114 |
|
| 115 |
configure_package_config_file( |
| 116 |
"Config.cmake.in" |
| 117 |
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" |
| 118 |
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" |
| 119 |
) |
| 120 |
|
| 121 |
install( |
| 122 |
FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" |
| 123 |
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" |
| 124 |
) |
| 125 |
|
| 126 |
install(TARGETS cubeb EXPORT "${PROJECT_NAME}Targets") |
| 127 |
install( |
| 128 |
EXPORT "${PROJECT_NAME}Targets" |
| 129 |
NAMESPACE "${PROJECT_NAME}::" |
| 130 |
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" |
| 131 |
) |
| 132 |
|
| 133 |
if(NOT BUNDLE_SPEEX) |
| 134 |
find_package(PkgConfig) |
| 135 |
if(PKG_CONFIG_FOUND) |
| 136 |
pkg_check_modules(speexdsp IMPORTED_TARGET speexdsp) |
| 137 |
if(speexdsp_FOUND) |
| 138 |
add_library(speex ALIAS PkgConfig::speexdsp) |
| 139 |
endif() |
| 140 |
endif() |
| 141 |
endif() |
| 142 |
|
| 143 |
if(NOT TARGET speex) |
| 144 |
add_library(speex OBJECT subprojects/speex/resample.c) |
| 145 |
set_target_properties(speex PROPERTIES POSITION_INDEPENDENT_CODE TRUE) |
| 146 |
target_include_directories(speex INTERFACE subprojects) |
| 147 |
target_compile_definitions(speex PUBLIC |
| 148 |
OUTSIDE_SPEEX |
| 149 |
FLOATING_POINT |
| 150 |
EXPORT= |
| 151 |
RANDOM_PREFIX=speex |
| 152 |
) |
| 153 |
endif() |
| 154 |
|
| 155 |
# $<BUILD_INTERFACE:> required because of https://gitlab.kitware.com/cmake/cmake/-/issues/15415 |
| 156 |
target_link_libraries(cubeb PRIVATE $<BUILD_INTERFACE:speex>) |
| 157 |
|
| 158 |
include(CheckIncludeFiles) |
| 159 |
|
| 160 |
# Threads needed by cubeb_log, _pulse, _alsa, _jack, _sndio, _oss and _sun |
| 161 |
set(THREADS_PREFER_PTHREAD_FLAG ON) |
| 162 |
find_package(Threads) |
| 163 |
target_link_libraries(cubeb PRIVATE Threads::Threads) |
| 164 |
|
| 165 |
if(LAZY_LOAD_LIBS) |
| 166 |
check_include_files(pulse/pulseaudio.h USE_PULSE) |
| 167 |
check_include_files(alsa/asoundlib.h USE_ALSA) |
| 168 |
check_include_files(jack/jack.h USE_JACK) |
| 169 |
check_include_files(sndio.h USE_SNDIO) |
| 170 |
check_include_files(aaudio/AAudio.h USE_AAUDIO) |
| 171 |
|
| 172 |
if(USE_PULSE OR USE_ALSA OR USE_JACK OR USE_SNDIO OR USE_AAUDIO) |
| 173 |
target_link_libraries(cubeb PRIVATE ${CMAKE_DL_LIBS}) |
| 174 |
|
| 175 |
if(ANDROID) |
| 176 |
target_compile_definitions(cubeb PRIVATE __ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__) |
| 177 |
endif() |
| 178 |
endif() |
| 179 |
|
| 180 |
else() |
| 181 |
|
| 182 |
find_package(PkgConfig REQUIRED) |
| 183 |
|
| 184 |
pkg_check_modules(libpulse IMPORTED_TARGET libpulse) |
| 185 |
if(libpulse_FOUND) |
| 186 |
set(USE_PULSE ON) |
| 187 |
target_compile_definitions(cubeb PRIVATE DISABLE_LIBPULSE_DLOPEN) |
| 188 |
target_link_libraries(cubeb PRIVATE PkgConfig::libpulse) |
| 189 |
endif() |
| 190 |
|
| 191 |
pkg_check_modules(alsa IMPORTED_TARGET alsa) |
| 192 |
if(alsa_FOUND) |
| 193 |
set(USE_ALSA ON) |
| 194 |
target_compile_definitions(cubeb PRIVATE DISABLE_LIBASOUND_DLOPEN) |
| 195 |
target_link_libraries(cubeb PRIVATE PkgConfig::alsa) |
| 196 |
endif() |
| 197 |
|
| 198 |
pkg_check_modules(jack IMPORTED_TARGET jack) |
| 199 |
if(jack_FOUND) |
| 200 |
set(USE_JACK ON) |
| 201 |
target_compile_definitions(cubeb PRIVATE DISABLE_LIBJACK_DLOPEN) |
| 202 |
target_link_libraries(cubeb PRIVATE PkgConfig::jack) |
| 203 |
endif() |
| 204 |
|
| 205 |
check_include_files(sndio.h USE_SNDIO) |
| 206 |
if(USE_SNDIO) |
| 207 |
target_compile_definitions(cubeb PRIVATE DISABLE_LIBSNDIO_DLOPEN) |
| 208 |
target_link_libraries(cubeb PRIVATE sndio) |
| 209 |
endif() |
| 210 |
|
| 211 |
check_include_files(aaudio/AAudio.h USE_AAUDIO) |
| 212 |
if(USE_AAUDIO) |
| 213 |
target_compile_definitions(cubeb PRIVATE DISABLE_LIBAAUDIO_DLOPEN) |
| 214 |
target_link_libraries(cubeb PRIVATE aaudio) |
| 215 |
endif() |
| 216 |
endif() |
| 217 |
|
| 218 |
if(USE_PULSE) |
| 219 |
target_sources(cubeb PRIVATE src/cubeb_pulse.c) |
| 220 |
target_compile_definitions(cubeb PRIVATE USE_PULSE) |
| 221 |
endif() |
| 222 |
|
| 223 |
if(USE_ALSA) |
| 224 |
target_sources(cubeb PRIVATE src/cubeb_alsa.c) |
| 225 |
target_compile_definitions(cubeb PRIVATE USE_ALSA) |
| 226 |
endif() |
| 227 |
|
| 228 |
if(USE_JACK) |
| 229 |
target_sources(cubeb PRIVATE src/cubeb_jack.cpp) |
| 230 |
target_compile_definitions(cubeb PRIVATE USE_JACK) |
| 231 |
endif() |
| 232 |
|
| 233 |
if(USE_SNDIO) |
| 234 |
target_sources(cubeb PRIVATE src/cubeb_sndio.c) |
| 235 |
target_compile_definitions(cubeb PRIVATE USE_SNDIO) |
| 236 |
endif() |
| 237 |
|
| 238 |
if(USE_AAUDIO) |
| 239 |
target_sources(cubeb PRIVATE src/cubeb_aaudio.cpp) |
| 240 |
target_compile_definitions(cubeb PRIVATE USE_AAUDIO) |
| 241 |
|
| 242 |
# set this definition to enable low latency mode. Possibly bad for battery |
| 243 |
target_compile_definitions(cubeb PRIVATE CUBEB_AAUDIO_LOW_LATENCY) |
| 244 |
|
| 245 |
# set this definition to enable power saving mode. Possibly resulting |
| 246 |
# in high latency |
| 247 |
# target_compile_definitions(cubeb PRIVATE CUBEB_AAUDIO_LOW_POWER_SAVING) |
| 248 |
|
| 249 |
# set this mode to make the backend use an exclusive stream. |
| 250 |
# will decrease latency. |
| 251 |
# target_compile_definitions(cubeb PRIVATE CUBEB_AAUDIO_EXCLUSIVE_STREAM) |
| 252 |
endif() |
| 253 |
|
| 254 |
check_include_files(AudioUnit/AudioUnit.h USE_AUDIOUNIT) |
| 255 |
if(USE_AUDIOUNIT) |
| 256 |
target_sources(cubeb PRIVATE |
| 257 |
src/cubeb_audiounit.cpp |
| 258 |
src/cubeb_osx_run_loop.cpp) |
| 259 |
target_compile_definitions(cubeb PRIVATE USE_AUDIOUNIT) |
| 260 |
target_link_libraries(cubeb PRIVATE "-framework AudioUnit" "-framework CoreAudio" "-framework CoreServices") |
| 261 |
endif() |
| 262 |
|
| 263 |
check_include_files(audioclient.h USE_WASAPI) |
| 264 |
if(USE_WASAPI) |
| 265 |
target_sources(cubeb PRIVATE |
| 266 |
src/cubeb_wasapi.cpp) |
| 267 |
target_compile_definitions(cubeb PRIVATE USE_WASAPI) |
| 268 |
target_link_libraries(cubeb PRIVATE ole32 ksuser) |
| 269 |
endif() |
| 270 |
|
| 271 |
check_include_files("windows.h;mmsystem.h" USE_WINMM) |
| 272 |
if(USE_WINMM) |
| 273 |
target_sources(cubeb PRIVATE |
| 274 |
src/cubeb_winmm.c) |
| 275 |
target_compile_definitions(cubeb PRIVATE USE_WINMM) |
| 276 |
target_link_libraries(cubeb PRIVATE winmm) |
| 277 |
endif() |
| 278 |
|
| 279 |
check_include_files(SLES/OpenSLES.h USE_OPENSL) |
| 280 |
if(USE_OPENSL) |
| 281 |
target_sources(cubeb PRIVATE |
| 282 |
src/cubeb_opensl.cpp |
| 283 |
src/cubeb-jni.cpp) |
| 284 |
target_compile_definitions(cubeb PRIVATE USE_OPENSL) |
| 285 |
target_link_libraries(cubeb PRIVATE OpenSLES) |
| 286 |
endif() |
| 287 |
|
| 288 |
check_include_files(sys/soundcard.h HAVE_SYS_SOUNDCARD_H) |
| 289 |
if(HAVE_SYS_SOUNDCARD_H) |
| 290 |
try_compile(USE_OSS "${PROJECT_BINARY_DIR}/compile_tests" |
| 291 |
${PROJECT_SOURCE_DIR}/cmake/compile_tests/oss_is_v4.c) |
| 292 |
if(USE_OSS) |
| 293 |
# strlcpy is not available on BSD systems that use glibc, |
| 294 |
# like Debian kfreebsd, so try using libbsd if available |
| 295 |
include(CheckSymbolExists) |
| 296 |
check_symbol_exists(strlcpy string.h HAVE_STRLCPY) |
| 297 |
if(NOT HAVE_STRLCPY) |
| 298 |
pkg_check_modules(libbsd-overlay IMPORTED_TARGET libbsd-overlay) |
| 299 |
if(libbsd-overlay_FOUND) |
| 300 |
target_link_libraries(cubeb PRIVATE PkgConfig::libbsd-overlay) |
| 301 |
set(HAVE_STRLCPY true) |
| 302 |
endif() |
| 303 |
endif() |
| 304 |
if (HAVE_STRLCPY) |
| 305 |
target_sources(cubeb PRIVATE |
| 306 |
src/cubeb_oss.c) |
| 307 |
target_compile_definitions(cubeb PRIVATE USE_OSS) |
| 308 |
endif() |
| 309 |
endif() |
| 310 |
endif() |
| 311 |
|
| 312 |
check_include_files(android/log.h USE_AUDIOTRACK) |
| 313 |
if(USE_AUDIOTRACK) |
| 314 |
target_sources(cubeb PRIVATE |
| 315 |
src/cubeb_audiotrack.c) |
| 316 |
target_compile_definitions(cubeb PRIVATE USE_AUDIOTRACK) |
| 317 |
target_link_libraries(cubeb PRIVATE log) |
| 318 |
endif() |
| 319 |
|
| 320 |
check_include_files(sys/audioio.h USE_SUN) |
| 321 |
if(USE_SUN) |
| 322 |
target_sources(cubeb PRIVATE |
| 323 |
src/cubeb_sun.c) |
| 324 |
target_compile_definitions(cubeb PRIVATE USE_SUN) |
| 325 |
endif() |
| 326 |
|
| 327 |
check_include_files(kai.h USE_KAI) |
| 328 |
if(USE_KAI) |
| 329 |
target_sources(cubeb PRIVATE |
| 330 |
src/cubeb_kai.c) |
| 331 |
target_compile_definitions(cubeb PRIVATE USE_KAI) |
| 332 |
target_link_libraries(cubeb PRIVATE kai) |
| 333 |
endif() |
| 334 |
|
| 335 |
if(USE_PULSE AND USE_PULSE_RUST) |
| 336 |
include(ExternalProject) |
| 337 |
set_directory_properties(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/rust) |
| 338 |
ExternalProject_Add( |
| 339 |
cubeb_pulse_rs |
| 340 |
DOWNLOAD_COMMAND "" |
| 341 |
CONFIGURE_COMMAND "" |
| 342 |
BUILD_COMMAND cargo build COMMAND cargo build --release |
| 343 |
BUILD_ALWAYS ON |
| 344 |
BINARY_DIR "${PROJECT_SOURCE_DIR}/src/cubeb-pulse-rs" |
| 345 |
INSTALL_COMMAND "" |
| 346 |
LOG_BUILD ON) |
| 347 |
add_dependencies(cubeb cubeb_pulse_rs) |
| 348 |
target_compile_definitions(cubeb PRIVATE USE_PULSE_RUST) |
| 349 |
target_link_libraries(cubeb PRIVATE |
| 350 |
debug "${PROJECT_SOURCE_DIR}/src/cubeb-pulse-rs/target/debug/libcubeb_pulse.a" |
| 351 |
optimized "${PROJECT_SOURCE_DIR}/src/cubeb-pulse-rs/target/release/libcubeb_pulse.a" pulse) |
| 352 |
endif() |
| 353 |
|
| 354 |
if(USE_AUDIOUNIT AND USE_AUDIOUNIT_RUST) |
| 355 |
include(ExternalProject) |
| 356 |
set_directory_properties(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/rust) |
| 357 |
ExternalProject_Add( |
| 358 |
cubeb_coreaudio_rs |
| 359 |
DOWNLOAD_COMMAND "" |
| 360 |
CONFIGURE_COMMAND "" |
| 361 |
BUILD_COMMAND cargo build COMMAND cargo build --release |
| 362 |
BUILD_ALWAYS ON |
| 363 |
BINARY_DIR "${PROJECT_SOURCE_DIR}/src/cubeb-coreaudio-rs" |
| 364 |
INSTALL_COMMAND "" |
| 365 |
LOG_BUILD ON) |
| 366 |
add_dependencies(cubeb cubeb_coreaudio_rs) |
| 367 |
target_compile_definitions(cubeb PRIVATE USE_AUDIOUNIT_RUST) |
| 368 |
target_link_libraries(cubeb PRIVATE |
| 369 |
debug "${PROJECT_SOURCE_DIR}/src/cubeb-coreaudio-rs/target/debug/libcubeb_coreaudio.a" |
| 370 |
optimized "${PROJECT_SOURCE_DIR}/src/cubeb-coreaudio-rs/target/release/libcubeb_coreaudio.a") |
| 371 |
endif() |
| 372 |
|
| 373 |
find_package(Doxygen) |
| 374 |
if(DOXYGEN_FOUND) |
| 375 |
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile @ONLY) |
| 376 |
add_custom_target(doc ALL |
| 377 |
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile |
| 378 |
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs |
| 379 |
COMMENT "Generating API documentation with Doxygen" VERBATIM) |
| 380 |
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs/html/ TYPE DOC) |
| 381 |
endif() |
| 382 |
|
| 383 |
if(BUILD_TESTS) |
| 384 |
enable_testing() |
| 385 |
|
| 386 |
macro(cubeb_add_test NAME) |
| 387 |
add_executable(test_${NAME} test/test_${NAME}.cpp) |
| 388 |
target_include_directories(test_${NAME} PRIVATE ${gtest_SOURCE_DIR}/include src) |
| 389 |
target_link_libraries(test_${NAME} PRIVATE cubeb gtest_main) |
| 390 |
add_test(${NAME} test_${NAME} --gtest_death_test_style=threadsafe) |
| 391 |
add_sanitizers(test_${NAME}) |
| 392 |
endmacro(cubeb_add_test) |
| 393 |
|
| 394 |
cubeb_add_test(sanity) |
| 395 |
cubeb_add_test(tone) |
| 396 |
cubeb_add_test(audio) |
| 397 |
cubeb_add_test(record) |
| 398 |
cubeb_add_test(devices) |
| 399 |
cubeb_add_test(callback_ret) |
| 400 |
|
| 401 |
add_executable(test_resampler test/test_resampler.cpp src/cubeb_resampler.cpp src/cubeb_log.cpp) |
| 402 |
target_include_directories(test_resampler PRIVATE ${gtest_SOURCE_DIR}/include src) |
| 403 |
target_link_libraries(test_resampler PRIVATE cubeb gtest_main speex) |
| 404 |
add_test(resampler test_resampler) |
| 405 |
add_sanitizers(test_resampler) |
| 406 |
|
| 407 |
cubeb_add_test(duplex) |
| 408 |
cubeb_add_test(logging) |
| 409 |
cubeb_add_test(triple_buffer) |
| 410 |
cubeb_add_test(audio_dump) |
| 411 |
|
| 412 |
if (USE_WASAPI) |
| 413 |
cubeb_add_test(overload_callback) |
| 414 |
cubeb_add_test(loopback) |
| 415 |
endif() |
| 416 |
|
| 417 |
cubeb_add_test(latency test_latency) |
| 418 |
cubeb_add_test(ring_array) |
| 419 |
|
| 420 |
cubeb_add_test(utils) |
| 421 |
cubeb_add_test(ring_buffer) |
| 422 |
cubeb_add_test(device_changed_callback) |
| 423 |
endif() |
| 424 |
|
| 425 |
if(BUILD_TOOLS) |
| 426 |
add_executable(cubeb-test tools/cubeb-test.cpp) |
| 427 |
target_include_directories(cubeb-test PRIVATE src) |
| 428 |
target_link_libraries(cubeb-test PRIVATE cubeb) |
| 429 |
add_sanitizers(cubeb-test) |
| 430 |
install(TARGETS cubeb-test) |
| 431 |
endif() |
| 432 |
|
| 433 |
if(NOT CLANG_FORMAT_BINARY) |
| 434 |
set(CLANG_FORMAT_BINARY clang-format) |
| 435 |
endif() |
| 436 |
|
| 437 |
add_custom_target(clang-format-check |
| 438 |
find |
| 439 |
${CMAKE_CURRENT_SOURCE_DIR}/src |
| 440 |
${CMAKE_CURRENT_SOURCE_DIR}/include |
| 441 |
${CMAKE_CURRENT_SOURCE_DIR}/test |
| 442 |
-type f (-name "*.cpp" -o -name "*.c" -o -name "*.h") |
| 443 |
-not -path "*/subprojects/speex/*" |
| 444 |
-print0 |
| 445 |
| xargs -0 ${CLANG_FORMAT_BINARY} -Werror -n |
| 446 |
COMMENT "Check formatting with clang-format" |
| 447 |
VERBATIM) |
| 448 |
|