Skip to content

Commit

Permalink
cmake/re-config: on some platforms linking atomic is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Dec 15, 2023
1 parent f708648 commit c1a1a49
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cmake/re-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include(CheckIncludeFile)
include(CheckFunctionExists)
include(CheckSymbolExists)
include(CheckTypeSize)
include(CheckCXXSourceCompiles)

option(USE_MBEDTLS "Enable MbedTLS" OFF)

Expand Down Expand Up @@ -214,3 +215,34 @@ if(NOT ${CMAKE_BUILD_TYPE} MATCHES "[Rr]el")
set(CMAKE_ENABLE_EXPORTS ON)
endif()
endif()

# Testing Atomic

enable_language(CXX)

set(ATOMIC32_TEST_CODE "
#include <atomic>
#include <stdint.h>
int main() {
std::atomic<int32_t> x;
x.store(1);
x--;
return x.load();
}")

set(ATOMIC64_TEST_CODE "
#include <atomic>
#include <stdint.h>
int main() {
std::atomic<int64_t> x;
x.store(1);
x--;
return x.load();
}")

check_cxx_source_compiles("${ATOMIC32_TEST_CODE}" atomic32_test)
check_cxx_source_compiles("${ATOMIC64_TEST_CODE}" atomic64_test)

if(NOT atomic32_test OR NOT atomic64_test)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} atomic)
endif()

0 comments on commit c1a1a49

Please sign in to comment.