diff --git a/cmake/re-config.cmake b/cmake/re-config.cmake index 6dc0ad8b6..eef923d70 100644 --- a/cmake/re-config.cmake +++ b/cmake/re-config.cmake @@ -2,6 +2,7 @@ include(CheckIncludeFile) include(CheckFunctionExists) include(CheckSymbolExists) include(CheckTypeSize) +include(CheckCXXSourceCompiles) option(USE_MBEDTLS "Enable MbedTLS" OFF) @@ -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 + #include + int main() { + std::atomic x; + x.store(1); + x--; + return x.load(); + }") + +set(ATOMIC64_TEST_CODE " + #include + #include + int main() { + std::atomic 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()