From a7ab58259e0c1ddb08a335be4c1ed0c7b6543ed1 Mon Sep 17 00:00:00 2001 From: David Reid Date: Wed, 20 Aug 2025 17:36:07 +1000 Subject: [PATCH 1/3] Don't try building C++ tests when forcing C89. --- CMakeLists.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fda3c47..d2c897c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -583,15 +583,18 @@ if(MINIAUDIO_BUILD_TESTS) target_link_libraries(${name} PRIVATE miniaudio_common_options) endfunction() - # The debugging test is only used for debugging miniaudio itself. Don't do add_test() for this, and do not include it in in any automated testing. - add_miniaudio_test(miniaudio_debugging debugging/debugging.cpp) + # Disable C++ tests when forcing C89. This is needed because we'll be passing -std=c89 which will cause errors when trying to compile a C++ file. + if(NOT MINIAUDIO_FORCE_C89) + # The debugging test is only used for debugging miniaudio itself. Don't do add_test() for this, and do not include it in in any automated testing. + add_miniaudio_test(miniaudio_debugging debugging/debugging.cpp) + + add_miniaudio_test(miniaudio_cpp cpp/cpp.cpp) + add_test(NAME miniaudio_cpp COMMAND miniaudio_cpp --auto) # This is just the deviceio test. + endif() add_miniaudio_test(miniaudio_deviceio deviceio/deviceio.c) add_test(NAME miniaudio_deviceio COMMAND miniaudio_deviceio --auto) - add_miniaudio_test(miniaudio_cpp cpp/cpp.cpp) - add_test(NAME miniaudio_cpp COMMAND miniaudio_cpp --auto) # This is just the deviceio test. - add_miniaudio_test(miniaudio_conversion conversion/conversion.c) add_test(NAME miniaudio_conversion COMMAND miniaudio_conversion) From ba84e61a184cf041a639a67f72c6c618e57f09e8 Mon Sep 17 00:00:00 2001 From: David Reid Date: Wed, 20 Aug 2025 18:03:12 +1000 Subject: [PATCH 2/3] Try fixing a compilation error when libatomic does not exist. --- CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2c897c0..fe03ce64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -452,9 +452,9 @@ set(COMMON_LINK_LIBRARIES) if (UNIX) if(NOT MINIAUDIO_NO_RUNTIME_LINKING) # Not all platforms actually use a separate "dl" library, notably NetBSD and OpenBSD. - find_library(LIB_DL "dl") + find_library(LIB_DL NAMES dl) if(LIB_DL) - 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 ${LIB_DL}) # For dlopen(), etc. Most compilers will link to this by default, but some may not. endif() endif() @@ -463,7 +463,10 @@ if (UNIX) # 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) + find_library(LIB_ATOMIC NAMES atomic) + if(LIB_ATOMIC) + list(APPEND COMMON_LINK_LIBRARIES ${LIB_ATOMIC}) + endif() endif() endif() From b7e5451ef42b8536db4a8e7637f53279e507c315 Mon Sep 17 00:00:00 2001 From: David Reid Date: Wed, 20 Aug 2025 18:07:59 +1000 Subject: [PATCH 3/3] Try fixing a compilation error when pthread does not exist. --- CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe03ce64..18e5261b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -458,8 +458,15 @@ if (UNIX) endif() endif() - 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) + find_library(LIB_PTHREAD NAMES pthread) + if(LIB_PTHREAD) + list(APPEND COMMON_LINK_LIBRARIES pthread) # Some compilers will not link to pthread by default so list it here just in case. + endif() + + find_library(LIB_M NAMES m) + if(LIB_M) + list(APPEND COMMON_LINK_LIBRARIES m) + endif() # 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")