8000 Fixed compile errors with clang/GCC on Linux. · unittest-cpp/unittest-cpp@d897476 · GitHub
[go: up one dir, main page]

Skip to content

Commit d897476

Browse files
Neil MacIntoshAnna Gringauze
authored andcommitted
Fixed compile errors with clang/GCC on Linux.
1 parent a32dd17 commit d897476

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ project(UnitTest++)
33

44
option(UTPP_USE_PLUS_SIGN "Set this to OFF is you with to use '-cpp' instead of '++' in lib/include paths" ON)
55

6+
if(MSVC14 OR MSVC12)
7+
# has the support we need
8+
else()
9+
include(CheckCXXCompilerFlag)
10+
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
11+
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
12+
if(COMPILER_SUPPORTS_CXX14)
13+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
14+
elseif(COMPILER_SUPPORTS_CXX11)
15+
CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
16+
else()
17+
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
18+
endif()
19+
endif()
20+
621
# get the main sources
722
file(GLOB headers_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.h)
823
file(GLOB sources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.cpp)

tests/TestTestMacros.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@ using namespace std;
2121
#define _NOEXCEPT_OP(x)
2222
#endif
2323
#endif
24-
25-
/* Test for GCC >= 4.8.0 */
26-
#ifdef __GNUC__
27-
#if (__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ > 7 ))
28-
#define _NOEXCEPT_OP(x) noexcept(x)
29-
#else
30-
#define _NOEXCEPT_OP(x)
24+
25+
#ifndef __clang__
26+
/* Test for GCC >= 4.8.0 */
27+
#ifdef __GNUC__
28+
#if (__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ > 7 ))
29+
#define _NOEXCEPT_OP(x) noexcept(x)
30+
#else
31+
#define _NOEXCEPT_OP(x)
32+
#endif
3133
#endif
3234
#endif
33-
3435
#endif
3536

3637
namespace {

0 commit comments

Comments
 (0)
0