From: David Wells Date: Thu, 6 Apr 2017 14:36:13 +0000 (-0400) Subject: Fix the check for compilers defaulting to C++11. X-Git-Tag: v9.0.0-rc1~1729^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=482e2f34851323394a26448ad8a5935f2e45a8e4;p=dealii.git Fix the check for compilers defaulting to C++11. Some compilers (notably clang on macOS) enable C++11 features as extensions even when __cplusplus == 199711 (i.e., compilation in C++98 mode). Mixing language versions in this way confuses some system headers (i..e., override versus throw()), so only treat the default compiler setting as C++11 if it sets the right value for __cplusplus. --- diff --git a/cmake/checks/check_01_cxx_features.cmake b/cmake/checks/check_01_cxx_features.cmake index fa7b3d31c4..b30fd69576 100644 --- a/cmake/checks/check_01_cxx_features.cmake +++ b/cmake/checks/check_01_cxx_features.cmake @@ -325,9 +325,14 @@ RESET_CMAKE_REQUIRED() CHECK_CXX_SOURCE_COMPILES( " #include - int main() + + #if __cplusplus < 201103L + # error \"The compiler does not default to C++11 or newer.\" + #endif + + auto main() -> int { - std::unique_ptr p0; + auto p0 = std::unique_ptr(); auto p1 = std::move(p0); } "