Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add check for libatomic
  • Loading branch information
K-ballo committed Sep 6, 2017
1 parent 3542836 commit eaad4fc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Expand Up @@ -1196,7 +1196,9 @@ if(NOT WIN32)
# System libraries
##############################################################################
if(NOT MSVC)
hpx_libraries(atomic)
if(HPX_HAVE_LIBATOMIC)
hpx_libraries(atomic)
endif()
endif()

if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
Expand Down
19 changes: 18 additions & 1 deletion cmake/HPX_AddConfigTest.cmake
Expand Up @@ -391,10 +391,27 @@ endmacro()

###############################################################################
macro(hpx_check_for_cxx11_std_atomic)
# Sometimes linking against libatomic is required for atomic ops, if
# the platform doesn't support lock-free atomics.

# First check if atomics work without the library.
add_hpx_config_test(HPX_WITH_CXX11_ATOMIC
SOURCE cmake/tests/cxx11_std_atomic.cpp
LIBRARIES "-latomic"
FILE ${ARGN})

# If not, check if the library exists, and atomics work with it.
if(NOT HPX_WITH_CXX11_ATOMIC)
check_library_exists(atomic __atomic_fetch_add_4 "" HPX_HAVE_LIBATOMIC)
if(HPX_HAVE_LIBATOMIC)
add_hpx_config_test(HPX_WITH_CXX11_ATOMIC
SOURCE cmake/tests/cxx11_std_atomic.cpp
LIBRARIES "atomic"
FILE ${ARGN})
else()
message(FATAL_ERROR
"Host compiler appears to require libatomic, but cannot find it.")
endif()
endif()
endmacro()

###############################################################################
Expand Down

0 comments on commit eaad4fc

Please sign in to comment.