]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix the check for compilers defaulting to C++11. 4201/head
authorDavid Wells <wellsd2@rpi.edu>
Thu, 6 Apr 2017 14:36:13 +0000 (10:36 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Thu, 6 Apr 2017 15:44:04 +0000 (11:44 -0400)
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.

cmake/checks/check_01_cxx_features.cmake

index fa7b3d31c4bcb82d757bf6f480e0fb9a79362c31..b30fd69576eb4aa8cc931de2e118c65f0e1b25f5 100644 (file)
@@ -325,9 +325,14 @@ RESET_CMAKE_REQUIRED()
 CHECK_CXX_SOURCE_COMPILES(
   "
   #include <memory>
-  int main()
+
+  #if __cplusplus < 201103L
+  #  error \"The compiler does not default to C++11 or newer.\"
+  #endif
+
+  auto main() -> int
   {
-    std::unique_ptr<int> p0;
+    auto p0 = std::unique_ptr<int>();
     auto p1 = std::move(p0);
   }
   "

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.