]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Refactor DEAL_II_HAVE_FP_EXCEPTIONS
authorMatthias Maier <tamiko@43-1.org>
Thu, 27 Aug 2015 22:23:21 +0000 (17:23 -0500)
committerMatthias Maier <tamiko@43-1.org>
Fri, 28 Aug 2015 15:43:17 +0000 (10:43 -0500)
 - this is a language feature, not a platform feature, so move it to
   check_01_cxx_features.cmake

 - A test that _runs_ code *_must_* be guarded with
   DEAL_II_ALLOW_PLATFORM_INTROSPECTION

 - Demote DEAL_II_HAVE_FP_EXCEPTIONS to an ordinary variable. Naming
   convetion: Variables starting with "DEAL_II_HAVE" must be ordinary
   variables, or internal, cached variables.

   Note: It is not necessary to promote DEAL_II_HAVE_FP_EXCEPTIONS to cache
   in order to override it with -DDEAL_II_HAVE_FP_EXCEPTIONS...

cmake/checks/check_01_cxx_features.cmake
cmake/checks/check_02_system_features.cmake
include/deal.II/base/config.h.in

index c39599d7a484489c255424fd3ef35cdb2fd13076..e154e345f231efb8276f2e0cf678c131a1a4ed1c 100644 (file)
@@ -25,6 +25,7 @@
 #   DEAL_II_HAVE_ISNAN
 #   DEAL_II_HAVE_UNDERSCORE_ISNAN
 #   DEAL_II_HAVE_ISFINITE
+#   DEAL_II_HAVE_FP_EXCEPTIONS
 #
 
 
@@ -463,3 +464,57 @@ CHECK_CXX_SOURCE_COMPILES(
   "
   DEAL_II_HAVE_ISFINITE)
 
+
+#
+# Check that we can use feenableexcept. Sets DEAL_II_HAVE_FP_EXCEPTIONS
+#
+# 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
+# string. This sadly happens with some compiler support libraries :-(
+#
+# - Timo Heister, 2015
+#
+
+IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
+  CHECK_CXX_SOURCE_RUNS(
+    "
+    #include <fenv.h>
+    #include <limits>
+    #include <sstream>
+
+    int main()
+    {
+      feenableexcept(FE_DIVBYZERO|FE_INVALID);
+      std::ostringstream description;
+      const double lower_bound = -std::numeric_limits<double>::max();
+
+      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>
+
+    int main()
+    {
+      feenableexcept(FE_DIVBYZERO|FE_INVALID);
+      std::ostringstream description;
+      const double lower_bound = -std::numeric_limits<double>::max();
+
+      description << lower_bound;
+
+      return 0;
+    }
+    "
+     DEAL_II_HAVE_FP_EXCEPTIONS)
+ENDIF()
index a9c1ac4550617b10e733416219fa4d85a6e6472d..655e5eb5614b7440d06c2257c3ef3d5c0c61b03b 100644 (file)
@@ -19,7 +19,6 @@
 #   DEAL_II_HAVE_GETHOSTNAME
 #   DEAL_II_HAVE_GETPID
 #   DEAL_II_HAVE_JN
-#   DEAL_II_HAVE_FP_EXCEPTIONS
 #   DEAL_II_HAVE_SYS_RESOURCE_H
 #   DEAL_II_HAVE_SYS_TIME_H
 #   DEAL_II_HAVE_SYS_TIMES_H
@@ -68,46 +67,6 @@ IF(NOT m_LIBRARY MATCHES "-NOTFOUND")
 ENDIF()
 
 
-#
-# Check that we can use feenableexcept. Sets DEAL_II_HAVE_FP_EXCEPTIONS
-#
-# 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
-# string. This sadly happens with some compiler support libraries :-(
-
-INCLUDE (CheckCXXSourceRuns)
-
-CHECK_CXX_SOURCE_RUNS("
-  #include <fenv.h>
-  #include <limits>
-  #include <sstream>
-
-  int main()
-  {
-    feenableexcept(FE_DIVBYZERO|FE_INVALID);
-    std::ostringstream description;
-    const double lower_bound = -std::numeric_limits<double>::max();  
-
-    description << lower_bound;
-
-    return 0;
-  }
-  " 
-  _HAVE_FP_EXCEPTIONS)
-
-
-SET(DEAL_II_HAVE_FP_EXCEPTIONS ON CACHE BOOL "If ON, floating point exception are raised in debug mode when running the testsuite.")
-
-IF (DEAL_II_HAVE_FP_EXCEPTIONS)
-  IF(_HAVE_FP_EXCEPTIONS)
-    MESSAGE(STATUS "Checking for Floating Point Exception macros -- Success")
-    # nothing to set here -- DEAL_II_HAVE_FP_EXCEPTIONS is already ON
-  ELSE()
-    MESSAGE(STATUS "Checking for Floating Point Exception macros -- Failed")
-    SET(DEAL_II_HAVE_FP_EXCEPTIONS OFF CACHE BOOL "" FORCE)
-  ENDIF()
-ENDIF()
-
 
 ########################################################################
 #                                                                      #
index 1e219c7e5f0f8c24bd61b126aca8f56519f65a4a..72863f63b24505d1fad826780260a9e98968d332 100644 (file)
 #cmakedefine DEAL_II_HAVE_STD_ISNAN
 #cmakedefine DEAL_II_HAVE_UNDERSCORE_ISNAN
 #cmakedefine DEAL_II_HAVE_ISFINITE
+#cmakedefine DEAL_II_HAVE_FP_EXCEPTIONS
 
 
 /***********************************************************************
 #cmakedefine DEAL_II_HAVE_GETPID
 #cmakedefine DEAL_II_HAVE_TIMES
 #cmakedefine DEAL_II_HAVE_JN
-#cmakedefine DEAL_II_HAVE_FP_EXCEPTIONS
 
 #cmakedefine DEAL_II_MSVC
 

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.