diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e65a157..a7b03d4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -462,18 +462,28 @@ 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() + + 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() - 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_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") - 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() @@ -614,15 +624,18 @@ if(MINIAUDIO_BUILD_TESTS) endif() 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)