From cda9a904b5ef76d923a072a45c0c15fd1d87d6be Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 19 Dec 2016 14:47:01 +0100 Subject: [PATCH] Explicitly link against libatomic on Linux/sparc for `__atomic_fetch_add_4` On this platform atomic instructions are implemented using `libatomic` so we need to link it to use them. --- Source/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index d15fdbe03d..388bf89858 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -785,6 +785,15 @@ target_link_libraries(CMakeLib cmsys ${CMake_KWIML_LIBRARIES} ) +if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc") + # the atomic instructions are implemented using libatomic on some platforms, + # so linking to that may be required + check_library_exists(atomic __atomic_fetch_add_4 "" LIBATOMIC_NEEDED) + if(LIBATOMIC_NEEDED) + target_link_libraries(CMakeLib atomic) + endif() +endif() + # On Apple we need CoreFoundation if(APPLE) target_link_libraries(CMakeLib "-framework CoreFoundation")