]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bugfix: Test for <cfenv> header instead of <fenv.h> 1449/head
authorMatthias Maier <tamiko@43-1.org>
Thu, 27 Aug 2015 22:48:15 +0000 (17:48 -0500)
committerMatthias Maier <tamiko@43-1.org>
Fri, 28 Aug 2015 15:43:17 +0000 (10:43 -0500)
We include the C++11 version <cfenv> in the testuite.

Silently, fix another test as well.

This fixes the testsuite for use in C++98/03 mode.

cmake/checks/check_01_cxx_features.cmake

index e154e345f231efb8276f2e0cf678c131a1a4ed1c..a21768720ec8f5e15955050d11823d7b9296926e 100644 (file)
@@ -424,13 +424,17 @@ ENDIF()
 # "-std=c++11" and "-std=c++14" but do not support
 # 'std::is_trivially_copyable', so check for support in C++11 or newer.
 #
-IF(DEAL_II_HAVE_CXX11)
+IF(DEAL_II_WITH_CXX11)
+  PUSH_CMAKE_REQUIRED("${DEAL_II_CXX_VERSION_FLAG}")
   CHECK_CXX_SOURCE_COMPILES(
     "
   #include <type_traits>
   int main(){ std::is_trivially_copyable<int> bob; }
   "
     DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE)
+  RESET_CMAKE_REQUIRED()
+ELSE()
+  SET(DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE FALSE)
 ENDIF()
 
 CHECK_CXX_SOURCE_COMPILES(
@@ -466,7 +470,7 @@ CHECK_CXX_SOURCE_COMPILES(
 
 
 #
-# Check that we can use feenableexcept. Sets DEAL_II_HAVE_FP_EXCEPTIONS
+# Check that we can use feenableexcept through the C++11 header file cfenv:
 #
 # The test is a bit more complicated because we also check that no garbage
 # exception is thrown if we convert -std::numeric_limits<double>::max to a
@@ -475,46 +479,53 @@ CHECK_CXX_SOURCE_COMPILES(
 # - Timo Heister, 2015
 #
 
-IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
-  CHECK_CXX_SOURCE_RUNS(
-    "
-    #include <fenv.h>
-    #include <limits>
-    #include <sstream>
+# This test requires C++11
+IF(DEAL_II_WITH_CXX11)
+  PUSH_CMAKE_REQUIRED("${DEAL_II_CXX_VERSION_FLAG}")
+  IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
+    CHECK_CXX_SOURCE_RUNS(
+      "
+      #include <cfenv>
+      #include <limits>
+      #include <sstream>
 
-    int main()
-    {
-      feenableexcept(FE_DIVBYZERO|FE_INVALID);
-      std::ostringstream description;
-      const double lower_bound = -std::numeric_limits<double>::max();
+      int main()
+      {
+        feenableexcept(FE_DIVBYZERO|FE_INVALID);
+        std::ostringstream description;
+        const double lower_bound = -std::numeric_limits<double>::max();
 
-      description << lower_bound;
+        description << lower_bound;
 
-      return 0;
-    }
-    "
-     DEAL_II_HAVE_FP_EXCEPTIONS)
-ELSE()
-  #
-  # If we are not allowed to do platform introspection, just test whether
-  # we can compile above code.
-  #
-  CHECK_CXX_SOURCE_COMPILES(
-    "
-    #include <fenv.h>
-    #include <limits>
-    #include <sstream>
+        return 0;
+      }
+      "
+       DEAL_II_HAVE_FP_EXCEPTIONS)
+  ELSE()
+    #
+    # If we are not allowed to do platform introspection, just test whether
+    # we can compile above code.
+    #
+    CHECK_CXX_SOURCE_COMPILES(
+      "
+      #include <cfenv>
+      #include <limits>
+      #include <sstream>
 
-    int main()
-    {
-      feenableexcept(FE_DIVBYZERO|FE_INVALID);
-      std::ostringstream description;
-      const double lower_bound = -std::numeric_limits<double>::max();
+      int main()
+      {
+        feenableexcept(FE_DIVBYZERO|FE_INVALID);
+        std::ostringstream description;
+        const double lower_bound = -std::numeric_limits<double>::max();
 
-      description << lower_bound;
+        description << lower_bound;
 
-      return 0;
-    }
-    "
-     DEAL_II_HAVE_FP_EXCEPTIONS)
+        return 0;
+      }
+      "
+       DEAL_II_HAVE_FP_EXCEPTIONS)
+  ENDIF()
+  RESET_CMAKE_REQUIRED()
+ELSE()
+  SET(DEAL_II_HAVE_FP_EXCEPTIONS FALSE)
 ENDIF()

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.