Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions CheckAtomic.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
include(CheckCXXSourceCompiles)

# Some toolchains require explicitly linking against libatomic
#
# If such linking is required, then this function sets the
# value of result to "atomic". Otherwise it remains untouched.
# This makes it so that the function only needs to be called once
# per project.
#
# It can be used as follows:
#
# check_cxx_needs_atomic(LINK_ATOMIC)
# target_link_libraries(foo PRIVATE ${LINK_ATOMIC})
# ...
# target_link_libraries(bar PRIVATE ${LINK_ATOMIC})
#
function(check_cxx_needs_atomic result)
check_cxx_source_compiles("
#include <atomic>
#include <cstdint>
int main() {
return std::atomic<uint64_t>(0).load();
}
" success)

if(NOT success)
set(${result} atomic PARENT_SCOPE)
endif()
endfunction()