aboutsummaryrefslogtreecommitdiffhomepage
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAndrea Pappacoda <[email protected]>2022-01-10 16:29:19 +0100
committerMatthew Gregan <[email protected]>2022-02-02 12:40:57 +1300
commitf79e0cf9f0620fe810b5ab034df698376197f444 (patch)
tree820d25a2923d65573920fdfdf51e188aaf7b8229 /CMakeLists.txt
parent7d62476a5a95e33f9976d208d884e248b9fd83e0 (diff)
downloadcubeb-f79e0cf9f0620fe810b5ab034df698376197f444.tar.gz
cubeb-f79e0cf9f0620fe810b5ab034df698376197f444.zip
build: use libbsd when using OSS and glibc
Some systems offer OSS v4 but do not have BSD-only functions like strlcpy, used in cubeb_oss.c. An example is Debian GNU/kFreeBSD, that uses a FreeBSD kernel with GNU userspace utilities, like glibc. With this patch cubeb will be able to build on these systems thanks to the help of libbsd, that privides most libc functions that you would expect on BSD.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt19
1 files changed, 16 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 90ccd18..f8aa66c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -284,9 +284,22 @@ 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)
- target_sources(cubeb PRIVATE
- src/cubeb_oss.c)
- target_compile_definitions(cubeb PRIVATE USE_OSS)
+ # 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()
endif()
endif()