Skip to content

Commit 14763a8

Browse files
committed
Fixed #905.
Added compiler version cheking for atomic test for older compilers on cmake.
1 parent 70912ff commit 14763a8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,11 @@ IF (GTEST_FOUND AND ZLIB_FOUND AND THREADS_FOUND AND NOT "${MSGPACK_FUZZ_REGRESS
115115
OPTION (MSGPACK_GEN_COVERAGE "Enable running gcov to get a test coverage report." OFF)
116116
ENDIF ()
117117

118-
INCLUDE (CheckCXXSourceCompiles)
119-
CHECK_CXX_SOURCE_COMPILES ("
118+
119+
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
120+
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.1)
121+
INCLUDE (CheckCXXSourceCompiles)
122+
CHECK_CXX_SOURCE_COMPILES ("
120123
#include <bits/atomicity.h>
121124
int atomic_sub(int i) { return __gnu_cxx::__exchange_and_add(&i, -1) - 1; }
122125
int atomic_add(int i) { return __gnu_cxx::__exchange_and_add(&i, 1) + 1; }
@@ -125,7 +128,11 @@ int main(int argc, char * argv[])
125128
atomic_sub(1);
126129
atomic_add(1);
127130
}
128-
" MSGPACK_ENABLE_GCC_CXX_ATOMIC)
131+
"
132+
MSGPACK_ENABLE_GCC_CXX_ATOMIC)
133+
ENDIF ()
134+
ENDIF ()
135+
129136

130137
INCLUDE (Files.cmake)
131138

0 commit comments

Comments
 (0)