diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 8931eca6..0aa090ae 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -27,7 +27,10 @@ macro(sfizz_add_benchmark TARGET) target_link_libraries("${TARGET}" PRIVATE absl::span absl::algorithm PRIVATE benchmark::benchmark benchmark::benchmark_main - PRIVATE bm_simd bm_ftz) + PRIVATE bm_simd bm_ftz) + if (LIBATOMIC_FOUND) + target_link_libraries ("${TARGET}" PRIVATE atomic) + endif() target_include_directories("${TARGET}" PRIVATE ../src/sfizz ../src/external) endmacro() diff --git a/cmake/SfizzConfig.cmake b/cmake/SfizzConfig.cmake index 19215e3a..0f5fc728 100644 --- a/cmake/SfizzConfig.cmake +++ b/cmake/SfizzConfig.cmake @@ -66,6 +66,11 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID) endif() endif() +include (CheckLibraryExists) +if (UNIX AND NOT APPLE) + check_library_exists(atomic __atomic_load "" LIBATOMIC_FOUND) +endif() + # Don't show build information when building a different project function (show_build_info_if_needed) if (CMAKE_PROJECT_NAME STREQUAL "sfizz") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fcaeca79..2475fd65 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,4 @@ include (GNUInstallDirs) -include (CheckLibraryExists) set (SFIZZ_SOURCES sfizz/Synth.cpp @@ -55,11 +54,8 @@ endif() add_library (sfizz::parser ALIAS sfizz_parser) add_library (sfizz::sfizz ALIAS sfizz_static) -if (UNIX AND NOT APPLE) - check_library_exists(atomic __atomic_load "" LIBATOMIC_FOUND) - if (LIBATOMIC_FOUND) - target_link_libraries (sfizz_static PRIVATE atomic) - endif() +if (LIBATOMIC_FOUND) + target_link_libraries (sfizz_static PRIVATE atomic) endif() # Shared library and installation target