]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Re-enable automatic detection of C++ versions.
authorDavid Wells <drwells@vt.edu>
Mon, 29 Jun 2015 03:11:55 +0000 (23:11 -0400)
committerDavid Wells <drwells@vt.edu>
Mon, 29 Jun 2015 03:21:17 +0000 (23:21 -0400)
I mistakenly removed this when adding C++14 support.

cmake/checks/check_01_cxx_features.cmake
doc/users/cmake.html

index 7884c45a100aa4cdeb67e579238d4af9913196ed..0170ce92a6a0a2f80bc87e2c47d4d3919488506a 100644 (file)
@@ -55,33 +55,62 @@ IF(DEAL_II_WITH_CXX14 AND DEFINED DEAL_II_WITH_CXX11 AND NOT DEAL_II_WITH_CXX11)
 ENDIF()
 
 #
-# Only run these tests if C++11 support (or newer) should actually be set up:
+# Test for C++11 flag support if the compiler supports a C++11 flag and C++11
+# support is not explicitly disabled.
 #
 
-IF(DEAL_II_WITH_CXX11 OR DEAL_II_WITH_CXX14)
-  IF(NOT DEAL_II_CXX_VERSION_FLAG)
-    IF(DEAL_II_WITH_CXX14)
-      CHECK_CXX_COMPILER_FLAG("-std=c++14" DEAL_II_HAVE_FLAG_stdcxx14)
-      IF(DEAL_II_HAVE_FLAG_stdcxx14)
-        SET(DEAL_II_CXX_VERSION_FLAG "-std=c++14")
-      ELSE()
-        MESSAGE(FATAL_ERROR
-          "CMake was not able to find a valid C++14 flag. Try manually"
-          " specifying\nDEAL_II_CXX_VERSION_FLAG\nand reruning CMake.")
-      ENDIF()
-    ELSEIF(DEAL_II_WITH_CXX11)
-      CHECK_CXX_COMPILER_FLAG("-std=c++0x" DEAL_II_HAVE_FLAG_stdcxx0x)
-      CHECK_CXX_COMPILER_FLAG("-std=c++11" DEAL_II_HAVE_FLAG_stdcxx11)
-      IF(DEAL_II_HAVE_FLAG_stdcxx11)
-        SET(DEAL_II_CXX_VERSION_FLAG "-std=c++11")
-      ELSEIF(DEAL_II_HAVE_FLAG_stdcxx0x)
-        SET(DEAL_II_CXX_VERSION_FLAG "-std=c++0x")
-      ELSE()
+IF((NOT DEFINED DEAL_II_WITH_CXX11 OR DEAL_II_WITH_CXX11)
+    AND NOT DEFINED DEAL_II_CXX_VERSION_FLAG)
+  CHECK_CXX_COMPILER_FLAG("-std=c++0x" DEAL_II_HAVE_FLAG_stdcxx0x)
+  CHECK_CXX_COMPILER_FLAG("-std=c++11" DEAL_II_HAVE_FLAG_stdcxx11)
+  IF(DEAL_II_HAVE_FLAG_stdcxx11)
+    SET(DEAL_II_CXX11_FLAG "-std=c++11")
+  ELSEIF(DEAL_II_HAVE_FLAG_stdcxx0x)
+    SET(DEAL_II_CXX11_FLAG "-std=c++0x")
+  ELSE()
+    IF(DEAL_II_WITH_CXX11)
+      MESSAGE(FATAL_ERROR
+        "C++11 support was requested but CMake was not able to find a valid C++11"
+        " flag. Try manually specifying DEAL_II_CXX_VERSION_FLAG and reruning CMake.")
+    ENDIF()
+  ENDIF()
+
+  #
+  # C++11 support must not be explicitly disabled for C++14 support to be
+  # enabled.
+  #
+
+  IF(NOT DEFINED DEAL_II_WITH_CXX14 OR DEAL_II_WITH_CXX14)
+    CHECK_CXX_COMPILER_FLAG("-std=c++1y" DEAL_II_HAVE_FLAG_stdcxx1y)
+    CHECK_CXX_COMPILER_FLAG("-std=c++14" DEAL_II_HAVE_FLAG_stdcxx14)
+    IF(DEAL_II_HAVE_FLAG_stdcxx14)
+      SET(DEAL_II_CXX14_FLAG "-std=c++14")
+    ELSEIF(DEAL_II_HAVE_FLAG_stdcxx1y)
+      SET(DEAL_II_CXX14_FLAG "-std=c++1y")
+    ELSE()
+      IF(DEAL_II_WITH_CXX14)
         MESSAGE(FATAL_ERROR
-          "CMake was not able to find a valid C++11 flag. Try manually"
-          " specifying\nDEAL_II_CXX_VERSION_FLAG and reruning CMake.")
+          "C++14 support was requested but CMake was not able to find a valid C++14"
+          " flag. Try manually specifying DEAL_II_CXX_VERSION_FLAG and reruning CMake.")
       ENDIF()
     ENDIF()
+  ENDIF()
+ENDIF()
+
+#
+# Only run these tests if CMake should attempt to set up C++11 (or newer)
+# support.
+#
+IF(DEFINED DEAL_II_CXX11_FLAG OR DEFINED DEAL_II_CXX14_FLAG
+    OR DEFINED DEAL_II_CXX_VERSION_FLAG)
+  IF(NOT DEFINED DEAL_II_CXX_VERSION_FLAG)
+    IF(DEFINED DEAL_II_CXX14_FLAG)
+      SET(DEAL_II_CXX_VERSION_FLAG ${DEAL_II_CXX14_FLAG})
+    ELSEIF(DEFINED DEAL_II_CXX11_FLAG)
+      SET(DEAL_II_CXX_VERSION_FLAG ${DEAL_II_CXX11_FLAG})
+    ELSE()
+      SET(DEAL_II_CXX_VERSION_FLAG " ")
+    ENDIF()
   ELSE()
     CHECK_CXX_COMPILER_FLAG(${DEAL_II_CXX_VERSION_FLAG} DEAL_II_CXX_VERSION_FLAG_VALID)
     IF(NOT DEAL_II_CXX_VERSION_FLAG_VALID)
@@ -286,8 +315,7 @@ IF(DEAL_II_WITH_CXX11 OR DEAL_II_WITH_CXX14)
     "
     DEAL_II_HAVE_CXX14_MAKE_UNIQUE)
   IF( DEAL_II_HAVE_CXX11 AND
-      DEAL_II_HAVE_CXX14_MAKE_UNIQUE AND
-      DEAL_II_WITH_CXX14)
+      DEAL_II_HAVE_CXX14_MAKE_UNIQUE)
     SET(DEAL_II_HAVE_CXX14 TRUE)
   ENDIF()
 
@@ -344,7 +372,7 @@ IF(DEAL_II_WITH_CXX14 AND NOT DEAL_II_HAVE_CXX14)
     "Please disable C++14 support, i.e. configure with\n"
     "    -DDEAL_II_WITH_CXX14=FALSE,\n"
     "or use a different compiler, instead. (If the compiler flag for C++14 "
-    "support differs from \"-std=c++14\", a suitable "
+    "support differs from \"-std=c++14\" or \"-std=c++1y\", a suitable "
     "compiler flag has to be specified manually via\n"
     "    -DDEAL_II_CXX_VERSION_FLAG=\"...\"\n\n"
     )
@@ -356,6 +384,7 @@ ENDIF()
 
 IF (DEAL_II_WITH_CXX14)
   ADD_FLAGS(DEAL_II_CXX_FLAGS "${DEAL_II_CXX_VERSION_FLAG}")
+  MESSAGE(STATUS "DEAL_II_WITH_CXX11 successfully set up")
   MESSAGE(STATUS "DEAL_II_WITH_CXX14 successfully set up")
 ELSEIF(DEAL_II_WITH_CXX11)
   ADD_FLAGS(DEAL_II_CXX_FLAGS "${DEAL_II_CXX_VERSION_FLAG}")
index 40363835a0ad07a6b07cffc8567f2a93dd6ab127..1f4913a35628256d43947e5b28b0d9fb2c3559a6 100644 (file)
@@ -432,12 +432,20 @@ parameter_gui  - builds and installs the 'parameter_gui' component
       by <code>cmake</code> variables that may be set to either <code>ON</code>
       or <code>OFF</code>.
 
-      By default, <acronym>deal.II</acronym> does not provide the compiler with
-      any <code>C++</code> version flag. If
-      either <code>DEAL_II_WITH_CXX11</code> or <code>DEAL_II_WITH_CXX14</code>
-      is set to <code>ON</code>, then <code>cmake</code> will attempt to
-      determine both the level of compliance and the correct compiler flag for
-      the requested language standard.
+      By default, <acronym>deal.II</acronym>'s <code>CMake</code> build scripts
+      will attempt to find the newest <code>C++</code> version available by
+      checking which language version flags work with the detected compiler. For
+      example: if <code>CMake</code> detects <code>GCC 5.1</code> or <code>Clang
+      3.6</code>, <acronym>deal.II</acronym> will be compiled
+      in <code>C++14</code> mode unless either <code>C++14</code>
+      or <code>C++11</code> is explicitly disabled. Another example:
+      if <code>DEAL_II_WITH_CXX11=ON</code> is passed to <code>CMake</code>,
+      then <acronym>deal.II</acronym> will check if the compiler supports enough
+      parts of the <code>C++11</code> <em>and</em>
+      <code>C++14</code> language standards. <code>CMake</code> will not fail in
+      this example just because the compiler does not support
+      <code>C++14</code>, but <code>CMake</code> <em>will</em> fail if the
+      compiler does not support enough of <code>C++11</code>.
 
       The remaining flags are set to <code>ON</code> if an external package is
       found or to <code>OFF</code> otherwise. By explicitly setting it to off

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.