Skip to content

Commit

Permalink
Add cmake check for libatomic requirement when building with gcc
Browse files Browse the repository at this point in the history
Fixes #980

Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
  • Loading branch information
glaubitz committed Dec 9, 2022
1 parent bc48c4a commit c544a08
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmake/compilers/GNU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ if (NOT MINGW)
set(TBB_COMMON_LINK_LIBS dl)
endif()

# Check whether code with full atomics can be built without libatomic
# see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81358
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("#include <atomic>
int main() {
std::atomic<uint8_t> w1;
std::atomic<uint16_t> w2;
std::atomic<uint32_t> w4;
std::atomic<uint64_t> w8;
return ++w1 + ++w2 + ++w4 + ++w8;
}" TBB_BUILDS_WITHOUT_LIBATOMIC)

if(NOT TBB_BUILDS_WITHOUT_LIBATOMIC)
set(TBB_COMMON_LINK_LIBS ${TBB_COMMON_LINK_LIBS} atomic)
endif()

# Ignore -Werror set through add_compile_options() or added to CMAKE_CXX_FLAGS if TBB_STRICT is disabled.
if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag)
tbb_remove_compile_flag(-Werror)
Expand Down

0 comments on commit c544a08

Please # to comment.