diff options
author | Rolf Eike Beer <eike@sf-mail.de> | 2016-12-19 13:47:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-01-09 20:51:35 (GMT) |
commit | cda9a904b5ef76d923a072a45c0c15fd1d87d6be (patch) | |
tree | 83be24ac97532f1ba1fc691d219e86ec1629b94b | |
parent | 4918cd8c98938ab245d7fea74ba6e20f3ec8ef8b (diff) | |
download | CMake-cda9a904b5ef76d923a072a45c0c15fd1d87d6be.zip CMake-cda9a904b5ef76d923a072a45c0c15fd1d87d6be.tar.gz CMake-cda9a904b5ef76d923a072a45c0c15fd1d87d6be.tar.bz2 |
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.
-rw-r--r-- | Source/CMakeLists.txt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index d15fdbe..388bf89 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") |