Skip to content

Commit

Permalink
Add more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Jan 2, 2024
1 parent 06c3ad4 commit 18ae719
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmake/libatomic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ if(CMAKE_CXX11_STANDARD_COMPILE_OPTION)
set(CMAKE_REQUIRED_FLAGS ${CMAKE_CXX11_STANDARD_COMPILE_OPTION})
endif()

# Check if code compiles without libatomic.
# Should always work on CPUs >= 64-bits
check_cxx_source_compiles("
#include <atomic>
#include <stdint.h>
Expand All @@ -25,10 +27,12 @@ check_cxx_source_compiles("
}"
atomic64)

# Our code requires libatomic to compile
if(NOT atomic64)
find_library(ATOMIC NAMES atomic atomic.so.1 libatomic.so.1)

if(ATOMIC)
# We have found libatomic, add it to the linker flags
set(LIBATOMIC ${ATOMIC})
message(STATUS "Found libatomic: ${LIBATOMIC}")
else()
Expand All @@ -55,6 +59,9 @@ if(NOT atomic64)
set(LIBATOMIC "-latomic")
message(STATUS "Add linker flag: ${LIBATOMIC}")
else()
# This code block is used to print a nice error message to the
# user. If atomic32 compiles and atomic64 does not compile then
# this is almost likely due to the missing libatomic library.
check_cxx_source_compiles("
#include <atomic>
#include <stdint.h>
Expand Down

0 comments on commit 18ae719

Please sign in to comment.