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.
This commit is contained in:
Rolf Eike Beer 2016-12-19 14:47:01 +01:00 committed by Brad King
parent 4918cd8c98
commit cda9a904b5

View File

@ -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")