2016-09-21 16:40:55 +03:00
|
|
|
# TODO
|
|
|
|
# - backend selection via command line, rather than simply detecting headers.
|
|
|
|
|
2021-11-23 02:35:11 +03:00
|
|
|
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
2016-09-21 16:40:55 +03:00
|
|
|
project(cubeb
|
|
|
|
VERSION 0.0.0)
|
|
|
|
|
2017-02-09 18:00:31 +03:00
|
|
|
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
2017-06-08 03:31:41 +03:00
|
|
|
option(BUILD_TESTS "Build tests" ON)
|
2018-10-17 12:59:16 +03:00
|
|
|
option(BUILD_RUST_LIBS "Build rust backends" OFF)
|
2019-02-01 12:30:40 +03:00
|
|
|
option(BUILD_TOOLS "Build tools" ON)
|
2021-11-07 02:09:57 +03:00
|
|
|
option(BUNDLE_SPEEX "Bundle the speex library" OFF)
|
2021-11-01 22:12:24 +03:00
|
|
|
option(LAZY_LOAD_LIBS "Lazily load shared libraries" ON)
|
2021-11-07 00:56:00 +03:00
|
|
|
option(USE_SANITIZERS "Use sanitizers" ON)
|
2017-02-09 18:00:31 +03:00
|
|
|
|
2016-10-19 22:39:36 +03:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
|
|
|
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
|
|
|
endif()
|
|
|
|
|
2016-09-21 16:40:55 +03:00
|
|
|
set(CMAKE_C_STANDARD 99)
|
2023-07-25 19:01:48 +03:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2016-09-21 16:40:55 +03:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2023-08-25 17:29:05 +03:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
2016-09-21 16:40:55 +03:00
|
|
|
|
2021-11-07 00:56:00 +03:00
|
|
|
if(USE_SANITIZERS)
|
2017-05-22 07:34:32 +03:00
|
|
|
if(NOT COMMAND add_sanitizers)
|
2021-11-07 00:56:00 +03:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake")
|
|
|
|
find_package(Sanitizers)
|
|
|
|
if(NOT COMMAND add_sanitizers)
|
|
|
|
message(FATAL_ERROR "Could not find sanitizers-cmake: run\n\tgit submodule update --init --recursive\nin base git checkout")
|
|
|
|
endif()
|
2017-05-22 07:34:32 +03:00
|
|
|
endif()
|
2021-11-07 00:56:00 +03:00
|
|
|
else()
|
|
|
|
macro(add_sanitizers UNUSED)
|
|
|
|
endmacro()
|
2017-05-15 05:54:35 +03:00
|
|
|
endif()
|
|
|
|
|
2017-06-08 03:31:41 +03:00
|
|
|
if(BUILD_TESTS)
|
2021-09-19 18:17:02 +03:00
|
|
|
find_package(GTest QUIET)
|
|
|
|
if(TARGET GTest::Main)
|
|
|
|
add_library(gtest_main ALIAS GTest::Main)
|
|
|
|
endif()
|
2017-06-08 03:31:41 +03:00
|
|
|
if(NOT TARGET gtest_main)
|
|
|
|
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/googletest/CMakeLists.txt")
|
|
|
|
message(FATAL_ERROR "Could not find googletest: run\n\tgit submodule update --init --recursive\nin base git checkout")
|
|
|
|
endif()
|
2020-10-29 12:58:20 +03:00
|
|
|
add_definitions(-DGTEST_HAS_TR1_TUPLE=0 -DGTEST_HAS_RTTI=0)
|
2017-06-08 03:31:41 +03:00
|
|
|
set(gtest_force_shared_crt ON CACHE BOOL "")
|
|
|
|
add_subdirectory(googletest)
|
2017-05-22 07:34:32 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
2016-11-10 05:43:49 +03:00
|
|
|
|
2018-10-17 12:59:16 +03:00
|
|
|
if (BUILD_RUST_LIBS)
|
|
|
|
if(EXISTS "${PROJECT_SOURCE_DIR}/src/cubeb-pulse-rs")
|
|
|
|
set(USE_PULSE_RUST 1)
|
|
|
|
endif()
|
2019-06-08 05:06:30 +03:00
|
|
|
if(EXISTS "${PROJECT_SOURCE_DIR}/src/cubeb-coreaudio-rs")
|
|
|
|
set(USE_AUDIOUNIT_RUST 1)
|
|
|
|
endif()
|
2018-10-17 12:59:16 +03:00
|
|
|
endif()
|
|
|
|
|
2017-10-20 07:43:40 +03:00
|
|
|
# On OS/2, visibility attribute is not supported.
|
|
|
|
if(NOT OS2)
|
|
|
|
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
|
|
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
|
|
|
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
|
|
|
|
endif()
|
2016-09-21 16:40:55 +03:00
|
|
|
|
2016-10-13 05:09:57 +03:00
|
|
|
set(CMAKE_CXX_WARNING_LEVEL 4)
|
|
|
|
if(NOT MSVC)
|
2016-11-14 07:15:27 +03:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter")
|
2020-10-28 20:17:19 +03:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -fno-exceptions -fno-rtti")
|
|
|
|
else()
|
2023-01-21 19:57:03 +03:00
|
|
|
string(REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # Disable RTTI
|
|
|
|
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # Disable Exceptions
|
2016-10-13 05:09:57 +03:00
|
|
|
endif()
|
|
|
|
|
2016-09-21 16:40:55 +03:00
|
|
|
add_library(cubeb
|
|
|
|
src/cubeb.c
|
2016-12-21 08:18:07 +03:00
|
|
|
src/cubeb_mixer.cpp
|
2016-09-21 16:40:55 +03:00
|
|
|
src/cubeb_resampler.cpp
|
2017-03-14 02:00:31 +03:00
|
|
|
src/cubeb_log.cpp
|
2017-05-15 04:15:20 +03:00
|
|
|
src/cubeb_strings.c
|
2018-03-19 16:57:07 +03:00
|
|
|
src/cubeb_utils.cpp
|
2021-11-07 02:09:57 +03:00
|
|
|
)
|
2017-10-20 07:43:40 +03:00
|
|
|
target_include_directories(cubeb
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>
|
2017-10-04 13:57:17 +03:00
|
|
|
)
|
2021-09-25 02:01:29 +03:00
|
|
|
set_target_properties(cubeb PROPERTIES
|
|
|
|
VERSION ${cubeb_VERSION}
|
|
|
|
SOVERSION ${cubeb_VERSION_MAJOR}
|
|
|
|
)
|
2016-09-21 16:40:55 +03:00
|
|
|
|
2017-05-19 10:06:38 +03:00
|
|
|
add_sanitizers(cubeb)
|
|
|
|
|
2016-09-21 16:40:55 +03:00
|
|
|
include(GenerateExportHeader)
|
|
|
|
generate_export_header(cubeb EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/exports/cubeb_export.h)
|
2017-10-20 07:43:40 +03:00
|
|
|
target_include_directories(cubeb
|
2017-10-04 13:57:17 +03:00
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/exports>
|
|
|
|
)
|
2016-09-21 16:40:55 +03:00
|
|
|
|
2021-11-09 12:34:05 +03:00
|
|
|
include(GNUInstallDirs)
|
2018-07-22 20:03:32 +03:00
|
|
|
|
2021-11-09 12:34:05 +03:00
|
|
|
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/${PROJECT_NAME} TYPE INCLUDE)
|
2018-07-22 20:03:32 +03:00
|
|
|
install(DIRECTORY ${CMAKE_BINARY_DIR}/exports/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
|
2017-06-08 03:31:41 +03:00
|
|
|
|
2017-10-04 13:57:17 +03:00
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
write_basic_package_version_file(
|
|
|
|
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
|
|
|
COMPATIBILITY SameMajorVersion
|
|
|
|
)
|
|
|
|
|
|
|
|
configure_package_config_file(
|
|
|
|
"Config.cmake.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
2018-07-22 20:03:32 +03:00
|
|
|
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
2017-10-04 13:57:17 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
install(
|
|
|
|
FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
2018-07-22 20:03:32 +03:00
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
2017-10-04 13:57:17 +03:00
|
|
|
)
|
2021-11-09 12:34:05 +03:00
|
|
|
|
|
|
|
install(TARGETS cubeb EXPORT "${PROJECT_NAME}Targets")
|
2017-10-04 13:57:17 +03:00
|
|
|
install(
|
|
|
|
EXPORT "${PROJECT_NAME}Targets"
|
|
|
|
NAMESPACE "${PROJECT_NAME}::"
|
2018-07-22 20:03:32 +03:00
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
2017-10-04 13:57:17 +03:00
|
|
|
)
|
|
|
|
|
2021-11-07 02:09:57 +03:00
|
|
|
if(NOT BUNDLE_SPEEX)
|
|
|
|
find_package(PkgConfig)
|
|
|
|
if(PKG_CONFIG_FOUND)
|
|
|
|
pkg_check_modules(speexdsp IMPORTED_TARGET speexdsp)
|
|
|
|
if(speexdsp_FOUND)
|
|
|
|
add_library(speex ALIAS PkgConfig::speexdsp)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT TARGET speex)
|
2022-03-09 05:10:52 +03:00
|
|
|
add_library(speex OBJECT subprojects/speex/resample.c)
|
2021-11-07 02:09:57 +03:00
|
|
|
set_target_properties(speex PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
|
|
|
target_include_directories(speex INTERFACE subprojects)
|
|
|
|
target_compile_definitions(speex PUBLIC
|
|
|
|
OUTSIDE_SPEEX
|
|
|
|
FLOATING_POINT
|
|
|
|
EXPORT=
|
|
|
|
RANDOM_PREFIX=speex
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# $<BUILD_INTERFACE:> required because of https://gitlab.kitware.com/cmake/cmake/-/issues/15415
|
|
|
|
target_link_libraries(cubeb PRIVATE $<BUILD_INTERFACE:speex>)
|
2016-09-21 16:40:55 +03:00
|
|
|
|
|
|
|
include(CheckIncludeFiles)
|
|
|
|
|
2021-11-01 22:12:24 +03:00
|
|
|
# Threads needed by cubeb_log, _pulse, _alsa, _jack, _sndio, _oss and _sun
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads)
|
|
|
|
target_link_libraries(cubeb PRIVATE Threads::Threads)
|
|
|
|
|
|
|
|
if(LAZY_LOAD_LIBS)
|
|
|
|
check_include_files(pulse/pulseaudio.h USE_PULSE)
|
|
|
|
check_include_files(alsa/asoundlib.h USE_ALSA)
|
|
|
|
check_include_files(jack/jack.h USE_JACK)
|
|
|
|
check_include_files(sndio.h USE_SNDIO)
|
|
|
|
check_include_files(aaudio/AAudio.h USE_AAUDIO)
|
|
|
|
|
|
|
|
if(USE_PULSE OR USE_ALSA OR USE_JACK OR USE_SNDIO OR USE_AAUDIO)
|
|
|
|
target_link_libraries(cubeb PRIVATE ${CMAKE_DL_LIBS})
|
2023-01-27 14:17:55 +03:00
|
|
|
|
|
|
|
if(ANDROID)
|
|
|
|
target_compile_definitions(cubeb PRIVATE __ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__)
|
|
|
|
endif()
|
2021-11-01 22:12:24 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
else()
|
|
|
|
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
|
|
|
|
pkg_check_modules(libpulse IMPORTED_TARGET libpulse)
|
|
|
|
if(libpulse_FOUND)
|
|
|
|
set(USE_PULSE ON)
|
|
|
|
target_compile_definitions(cubeb PRIVATE DISABLE_LIBPULSE_DLOPEN)
|
|
|
|
target_link_libraries(cubeb PRIVATE PkgConfig::libpulse)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
pkg_check_modules(alsa IMPORTED_TARGET alsa)
|
|
|
|
if(alsa_FOUND)
|
|
|
|
set(USE_ALSA ON)
|
|
|
|
target_compile_definitions(cubeb PRIVATE DISABLE_LIBASOUND_DLOPEN)
|
|
|
|
target_link_libraries(cubeb PRIVATE PkgConfig::alsa)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
pkg_check_modules(jack IMPORTED_TARGET jack)
|
|
|
|
if(jack_FOUND)
|
|
|
|
set(USE_JACK ON)
|
|
|
|
target_compile_definitions(cubeb PRIVATE DISABLE_LIBJACK_DLOPEN)
|
|
|
|
target_link_libraries(cubeb PRIVATE PkgConfig::jack)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_include_files(sndio.h USE_SNDIO)
|
|
|
|
if(USE_SNDIO)
|
|
|
|
target_compile_definitions(cubeb PRIVATE DISABLE_LIBSNDIO_DLOPEN)
|
|
|
|
target_link_libraries(cubeb PRIVATE sndio)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_include_files(aaudio/AAudio.h USE_AAUDIO)
|
|
|
|
if(USE_AAUDIO)
|
|
|
|
target_compile_definitions(cubeb PRIVATE DISABLE_LIBAAUDIO_DLOPEN)
|
|
|
|
target_link_libraries(cubeb PRIVATE aaudio)
|
|
|
|
endif()
|
2016-09-21 16:40:55 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_PULSE)
|
2021-11-01 22:12:24 +03:00
|
|
|
target_sources(cubeb PRIVATE src/cubeb_pulse.c)
|
2016-09-21 16:40:55 +03:00
|
|
|
target_compile_definitions(cubeb PRIVATE USE_PULSE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_ALSA)
|
2021-11-01 22:12:24 +03:00
|
|
|
target_sources(cubeb PRIVATE src/cubeb_alsa.c)
|
2016-09-21 16:40:55 +03:00
|
|
|
target_compile_definitions(cubeb PRIVATE USE_ALSA)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_JACK)
|
2021-11-01 22:12:24 +03:00
|
|
|
target_sources(cubeb PRIVATE src/cubeb_jack.cpp)
|
2016-09-21 16:40:55 +03:00
|
|
|
target_compile_definitions(cubeb PRIVATE USE_JACK)
|
2021-11-01 22:12:24 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_SNDIO)
|
|
|
|
target_sources(cubeb PRIVATE src/cubeb_sndio.c)
|
|
|
|
target_compile_definitions(cubeb PRIVATE USE_SNDIO)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_AAUDIO)
|
|
|
|
target_sources(cubeb PRIVATE src/cubeb_aaudio.cpp)
|
|
|
|
target_compile_definitions(cubeb PRIVATE USE_AAUDIO)
|
|
|
|
|
|
|
|
# set this definition to enable low latency mode. Possibly bad for battery
|
|
|
|
target_compile_definitions(cubeb PRIVATE CUBEB_AAUDIO_LOW_LATENCY)
|
|
|
|
|
|
|
|
# set this definition to enable power saving mode. Possibly resulting
|
|
|
|
# in high latency
|
|
|
|
# target_compile_definitions(cubeb PRIVATE CUBEB_AAUDIO_LOW_POWER_SAVING)
|
|
|
|
|
|
|
|
# set this mode to make the backend use an exclusive stream.
|
|
|
|
# will decrease latency.
|
|
|
|
# target_compile_definitions(cubeb PRIVATE CUBEB_AAUDIO_EXCLUSIVE_STREAM)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_include_files(AudioUnit/AudioUnit.h USE_AUDIOUNIT)
|
|
|
|
if(USE_AUDIOUNIT)
|
|
|
|
target_sources(cubeb PRIVATE
|
|
|
|
src/cubeb_audiounit.cpp
|
|
|
|
src/cubeb_osx_run_loop.cpp)
|
|
|
|
target_compile_definitions(cubeb PRIVATE USE_AUDIOUNIT)
|
|
|
|
target_link_libraries(cubeb PRIVATE "-framework AudioUnit" "-framework CoreAudio" "-framework CoreServices")
|
2016-09-21 16:40:55 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
check_include_files(audioclient.h USE_WASAPI)
|
|
|
|
if(USE_WASAPI)
|
|
|
|
target_sources(cubeb PRIVATE
|
|
|
|
src/cubeb_wasapi.cpp)
|
|
|
|
target_compile_definitions(cubeb PRIVATE USE_WASAPI)
|
2024-03-15 15:30:55 +03:00
|
|
|
target_link_libraries(cubeb PRIVATE ole32 ksuser)
|
2016-09-21 16:40:55 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
check_include_files("windows.h;mmsystem.h" USE_WINMM)
|
|
|
|
if(USE_WINMM)
|
|
|
|
target_sources(cubeb PRIVATE
|
|
|
|
src/cubeb_winmm.c)
|
|
|
|
target_compile_definitions(cubeb PRIVATE USE_WINMM)
|
|
|
|
target_link_libraries(cubeb PRIVATE winmm)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_include_files(SLES/OpenSLES.h USE_OPENSL)
|
|
|
|
if(USE_OPENSL)
|
|
|
|
target_sources(cubeb PRIVATE
|
2023-08-17 18:09:14 +03:00
|
|
|
src/cubeb_opensl.cpp
|
2018-02-19 18:50:15 +03:00
|
|
|
src/cubeb-jni.cpp)
|
2016-09-21 16:40:55 +03:00
|
|
|
target_compile_definitions(cubeb PRIVATE USE_OPENSL)
|
|
|
|
target_link_libraries(cubeb PRIVATE OpenSLES)
|
|
|
|
endif()
|
|
|
|
|
2020-10-09 20:09:39 +03:00
|
|
|
check_include_files(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
|
|
|
|
if(HAVE_SYS_SOUNDCARD_H)
|
|
|
|
try_compile(USE_OSS "${PROJECT_BINARY_DIR}/compile_tests"
|
|
|
|
${PROJECT_SOURCE_DIR}/cmake/compile_tests/oss_is_v4.c)
|
|
|
|
if(USE_OSS)
|
2022-01-10 18:29:19 +03:00
|
|
|
# strlcpy is not available on BSD systems that use glibc,
|
|
|
|
# like Debian kfreebsd, so try using libbsd if available
|
|
|
|
include(CheckSymbolExists)
|
|
|
|
check_symbol_exists(strlcpy string.h HAVE_STRLCPY)
|
|
|
|
if(NOT HAVE_STRLCPY)
|
|
|
|
pkg_check_modules(libbsd-overlay IMPORTED_TARGET libbsd-overlay)
|
|
|
|
if(libbsd-overlay_FOUND)
|
|
|
|
target_link_libraries(cubeb PRIVATE PkgConfig::libbsd-overlay)
|
|
|
|
set(HAVE_STRLCPY true)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if (HAVE_STRLCPY)
|
|
|
|
target_sources(cubeb PRIVATE
|
|
|
|
src/cubeb_oss.c)
|
|
|
|
target_compile_definitions(cubeb PRIVATE USE_OSS)
|
|
|
|
endif()
|
2020-10-09 20:09:39 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-09-21 16:40:55 +03:00
|
|
|
check_include_files(android/log.h USE_AUDIOTRACK)
|
|
|
|
if(USE_AUDIOTRACK)
|
|
|
|
target_sources(cubeb PRIVATE
|
|
|
|
src/cubeb_audiotrack.c)
|
|
|
|
target_compile_definitions(cubeb PRIVATE USE_AUDIOTRACK)
|
2016-11-18 08:32:21 +03:00
|
|
|
target_link_libraries(cubeb PRIVATE log)
|
2016-09-21 16:40:55 +03:00
|
|
|
endif()
|
|
|
|
|
2019-06-12 01:35:08 +03:00
|
|
|
check_include_files(sys/audioio.h USE_SUN)
|
|
|
|
if(USE_SUN)
|
|
|
|
target_sources(cubeb PRIVATE
|
|
|
|
src/cubeb_sun.c)
|
|
|
|
target_compile_definitions(cubeb PRIVATE USE_SUN)
|
|
|
|
endif()
|
|
|
|
|
2016-09-21 16:40:55 +03:00
|
|
|
check_include_files(kai.h USE_KAI)
|
|
|
|
if(USE_KAI)
|
|
|
|
target_sources(cubeb PRIVATE
|
|
|
|
src/cubeb_kai.c)
|
|
|
|
target_compile_definitions(cubeb PRIVATE USE_KAI)
|
|
|
|
target_link_libraries(cubeb PRIVATE kai)
|
|
|
|
endif()
|
2018-10-17 12:59:16 +03:00
|
|
|
|
2020-08-17 16:32:19 +03:00
|
|
|
if(USE_PULSE AND USE_PULSE_RUST)
|
2018-10-17 12:59:16 +03:00
|
|
|
include(ExternalProject)
|
|
|
|
set_directory_properties(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/rust)
|
|
|
|
ExternalProject_Add(
|
|
|
|
cubeb_pulse_rs
|
|
|
|
DOWNLOAD_COMMAND ""
|
|
|
|
CONFIGURE_COMMAND ""
|
|
|
|
BUILD_COMMAND cargo build COMMAND cargo build --release
|
2020-03-24 03:10:11 +03:00
|
|
|
BUILD_ALWAYS ON
|
2020-08-17 16:32:19 +03:00
|
|
|
BINARY_DIR "${PROJECT_SOURCE_DIR}/src/cubeb-pulse-rs"
|
2018-10-17 12:59:16 +03:00
|
|
|
INSTALL_COMMAND ""
|
|
|
|
LOG_BUILD ON)
|
|
|
|
add_dependencies(cubeb cubeb_pulse_rs)
|
|
|
|
target_compile_definitions(cubeb PRIVATE USE_PULSE_RUST)
|
|
|
|
target_link_libraries(cubeb PRIVATE
|
2020-08-17 16:32:19 +03:00
|
|
|
debug "${PROJECT_SOURCE_DIR}/src/cubeb-pulse-rs/target/debug/libcubeb_pulse.a"
|
|
|
|
optimized "${PROJECT_SOURCE_DIR}/src/cubeb-pulse-rs/target/release/libcubeb_pulse.a" pulse)
|
2018-10-17 12:59:16 +03:00
|
|
|
endif()
|
2016-09-21 16:40:55 +03:00
|
|
|
|
2020-08-17 16:32:19 +03:00
|
|
|
if(USE_AUDIOUNIT AND USE_AUDIOUNIT_RUST)
|
2019-06-08 05:06:30 +03:00
|
|
|
include(ExternalProject)
|
|
|
|
set_directory_properties(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/rust)
|
|
|
|
ExternalProject_Add(
|
|
|
|
cubeb_coreaudio_rs
|
|
|
|
DOWNLOAD_COMMAND ""
|
|
|
|
CONFIGURE_COMMAND ""
|
|
|
|
BUILD_COMMAND cargo build COMMAND cargo build --release
|
2020-03-24 03:10:11 +03:00
|
|
|
BUILD_ALWAYS ON
|
2020-08-17 16:32:19 +03:00
|
|
|
BINARY_DIR "${PROJECT_SOURCE_DIR}/src/cubeb-coreaudio-rs"
|
2019-06-08 05:06:30 +03:00
|
|
|
INSTALL_COMMAND ""
|
|
|
|
LOG_BUILD ON)
|
|
|
|
add_dependencies(cubeb cubeb_coreaudio_rs)
|
|
|
|
target_compile_definitions(cubeb PRIVATE USE_AUDIOUNIT_RUST)
|
|
|
|
target_link_libraries(cubeb PRIVATE
|
2020-08-17 16:32:19 +03:00
|
|
|
debug "${PROJECT_SOURCE_DIR}/src/cubeb-coreaudio-rs/target/debug/libcubeb_coreaudio.a"
|
|
|
|
optimized "${PROJECT_SOURCE_DIR}/src/cubeb-coreaudio-rs/target/release/libcubeb_coreaudio.a")
|
2019-06-08 05:06:30 +03:00
|
|
|
endif()
|
|
|
|
|
2016-09-21 16:40:55 +03:00
|
|
|
find_package(Doxygen)
|
|
|
|
if(DOXYGEN_FOUND)
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile @ONLY)
|
|
|
|
add_custom_target(doc ALL
|
|
|
|
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs
|
|
|
|
COMMENT "Generating API documentation with Doxygen" VERBATIM)
|
2022-09-16 01:22:02 +03:00
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs/html/ TYPE DOC)
|
2016-09-21 16:40:55 +03:00
|
|
|
endif()
|
|
|
|
|
2017-06-08 03:31:41 +03:00
|
|
|
if(BUILD_TESTS)
|
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
macro(cubeb_add_test NAME)
|
|
|
|
add_executable(test_${NAME} test/test_${NAME}.cpp)
|
2021-11-07 02:09:57 +03:00
|
|
|
target_include_directories(test_${NAME} PRIVATE ${gtest_SOURCE_DIR}/include src)
|
2017-06-08 03:31:41 +03:00
|
|
|
target_link_libraries(test_${NAME} PRIVATE cubeb gtest_main)
|
2022-02-24 03:27:11 +03:00
|
|
|
add_test(${NAME} test_${NAME} --gtest_death_test_style=threadsafe)
|
2017-06-08 03:31:41 +03:00
|
|
|
add_sanitizers(test_${NAME})
|
|
|
|
endmacro(cubeb_add_test)
|
|
|
|
|
|
|
|
cubeb_add_test(sanity)
|
|
|
|
cubeb_add_test(tone)
|
|
|
|
cubeb_add_test(audio)
|
|
|
|
cubeb_add_test(record)
|
|
|
|
cubeb_add_test(devices)
|
2018-02-05 19:09:51 +03:00
|
|
|
cubeb_add_test(callback_ret)
|
2017-06-08 03:31:41 +03:00
|
|
|
|
2021-11-07 02:09:57 +03:00
|
|
|
add_executable(test_resampler test/test_resampler.cpp src/cubeb_resampler.cpp src/cubeb_log.cpp)
|
|
|
|
target_include_directories(test_resampler PRIVATE ${gtest_SOURCE_DIR}/include src)
|
|
|
|
target_link_libraries(test_resampler PRIVATE cubeb gtest_main speex)
|
2017-06-08 03:31:41 +03:00
|
|
|
add_test(resampler test_resampler)
|
|
|
|
add_sanitizers(test_resampler)
|
|
|
|
|
|
|
|
cubeb_add_test(duplex)
|
2022-11-29 21:08:49 +03:00
|
|
|
cubeb_add_test(logging)
|
2022-12-13 21:30:46 +03:00
|
|
|
cubeb_add_test(triple_buffer)
|
2017-06-08 03:31:41 +03:00
|
|
|
|
|
|
|
if (USE_WASAPI)
|
|
|
|
cubeb_add_test(overload_callback)
|
2017-11-21 17:31:36 +03:00
|
|
|
cubeb_add_test(loopback)
|
2017-06-08 03:31:41 +03:00
|
|
|
endif()
|
2017-04-07 13:23:11 +03:00
|
|
|
|
2017-06-08 03:31:41 +03:00
|
|
|
cubeb_add_test(latency test_latency)
|
|
|
|
cubeb_add_test(ring_array)
|
|
|
|
|
|
|
|
cubeb_add_test(utils)
|
|
|
|
cubeb_add_test(ring_buffer)
|
2019-01-04 21:30:28 +03:00
|
|
|
cubeb_add_test(device_changed_callback)
|
2017-04-07 13:23:11 +03:00
|
|
|
endif()
|
2019-02-01 12:30:40 +03:00
|
|
|
|
|
|
|
if(BUILD_TOOLS)
|
|
|
|
add_executable(cubeb-test tools/cubeb-test.cpp)
|
|
|
|
target_include_directories(cubeb-test PRIVATE src)
|
|
|
|
target_link_libraries(cubeb-test PRIVATE cubeb)
|
|
|
|
add_sanitizers(cubeb-test)
|
2021-11-09 12:34:05 +03:00
|
|
|
install(TARGETS cubeb-test)
|
2019-02-01 12:30:40 +03:00
|
|
|
endif()
|
2021-07-28 01:34:39 +03:00
|
|
|
|
2023-05-02 14:54:01 +03:00
|
|
|
if(NOT CLANG_FORMAT_BINARY)
|
|
|
|
set(CLANG_FORMAT_BINARY clang-format)
|
|
|
|
endif()
|
|
|
|
|
2021-07-28 01:34:39 +03:00
|
|
|
add_custom_target(clang-format-check
|
|
|
|
find
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
2023-11-10 16:15:28 +03:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test
|
2021-07-28 01:34:39 +03:00
|
|
|
-type f (-name "*.cpp" -o -name "*.c" -o -name "*.h")
|
2021-11-07 02:09:57 +03:00
|
|
|
-not -path "*/subprojects/speex/*"
|
2021-07-28 01:34:39 +03:00
|
|
|
-print0
|
2023-05-02 14:54:01 +03:00
|
|
|
| xargs -0 ${CLANG_FORMAT_BINARY} -Werror -n
|
2021-07-28 01:34:39 +03:00
|
|
|
COMMENT "Check formatting with clang-format"
|
|
|
|
VERBATIM)
|
|
|
|
|