Skip to content

Commit

Permalink
Fixed msgpack#905.
Browse files Browse the repository at this point in the history
Added compiler version cheking for atomic test for older compilers on cmake.
  • Loading branch information
redboltz committed Jul 31, 2020
1 parent 70912ff commit 14763a8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ IF (GTEST_FOUND AND ZLIB_FOUND AND THREADS_FOUND AND NOT "${MSGPACK_FUZZ_REGRESS
OPTION (MSGPACK_GEN_COVERAGE "Enable running gcov to get a test coverage report." OFF)
ENDIF ()

INCLUDE (CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES ("

IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.1)
INCLUDE (CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES ("
#include <bits/atomicity.h>
int atomic_sub(int i) { return __gnu_cxx::__exchange_and_add(&i, -1) - 1; }
int atomic_add(int i) { return __gnu_cxx::__exchange_and_add(&i, 1) + 1; }
Expand All @@ -125,7 +128,11 @@ int main(int argc, char * argv[])
atomic_sub(1);
atomic_add(1);
}
" MSGPACK_ENABLE_GCC_CXX_ATOMIC)
"
MSGPACK_ENABLE_GCC_CXX_ATOMIC)
ENDIF ()
ENDIF ()


INCLUDE (Files.cmake)

Expand Down

0 comments on commit 14763a8

Please sign in to comment.