From 57eadc7a93814c0d348b60ecaf8a9a0f44a19671 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 7 Mar 2020 14:18:47 +0100 Subject: [PATCH] Global definition of LIBATOMIC_FOUND for arm benchmarks --- benchmarks/CMakeLists.txt | 5 ++++- cmake/SfizzConfig.cmake | 5 +++++ src/CMakeLists.txt | 8 ++------ 3 files changed, 11 insertions(+), 7 deletions(-) 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