]> https://gitweb.dealii.org/ - dealii.git/commitdiff
update configuration
authorMatthias Maier <tamiko@43-1.org>
Fri, 22 May 2020 02:34:35 +0000 (21:34 -0500)
committerMatthias Maier <tamiko@43-1.org>
Sat, 23 May 2020 14:56:12 +0000 (09:56 -0500)
cmake/checks/check_01_cxx_features.cmake
cmake/checks/check_02_compiler_features.cmake
cmake/config/CMakeLists.txt
cmake/configure/configure_1_cuda.cmake
cmake/setup_compiler_flags_gnu.cmake
include/deal.II/base/config.h.in

index 4205ffe002e8900a14918a836d71a53a8e64390f..151e50b65a078db27f549a99a7a16f5d31a089ec 100644 (file)
@@ -25,6 +25,7 @@
 #   DEAL_II_HAVE_CXX14_CONSTEXPR
 #   DEAL_II_HAVE_FP_EXCEPTIONS
 #   DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
+#   DEAL_II_DEPRECATED
 #
 #   DEAL_II_CONSTEXPR
 #   DEAL_II_FALLTHROUGH
@@ -259,8 +260,14 @@ ENDIF()
 #                                                                      #
 ########################################################################
 
+
+ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_FLAGS} ${_werror_flag}")
+IF(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+  ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Wno-unused-command-line-argument")
+ENDIF()
+
 UNSET_IF_CHANGED(CHECK_CXX_FEATURES_FLAGS_SAVED
-  "${CMAKE_REQUIRED_FLAGS}${DEAL_II_CXX_VERSION_FLAG}${DEAL_II_WITH_CXX14}${DEAL_II_WITH_CXX17}"
+  "${CMAKE_REQUIRED_FLAGS}"
   DEAL_II_HAVE_ATTRIBUTE_FALLTHROUGH
   DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE
   DEAL_II_HAVE_CXX14_CONSTEXPR
@@ -270,17 +277,7 @@ UNSET_IF_CHANGED(CHECK_CXX_FEATURES_FLAGS_SAVED
 
 #
 # Try to enable a fallthrough attribute. This is a language feature in C++17,
-# but a compiler extension in earlier language versions: check both
-# possibilities here.
-#
-ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_FLAGS}")
-ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${_werror_flag}")
-IF(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
-  ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Wno-unused-command-line-argument")
-ENDIF()
-
-#
-# first try the attribute [[fallthrough]]
+# but a compiler extension in earlier language versions.
 #
 CHECK_CXX_SOURCE_COMPILES(
   "
@@ -330,7 +327,6 @@ CHECK_CXX_SOURCE_COMPILES(
   DEAL_II_HAVE_ATTRIBUTE_FALLTHROUGH
   )
 
-RESET_CMAKE_REQUIRED()
 IF(DEAL_II_HAVE_CXX17_ATTRIBUTE_FALLTHROUGH)
   SET(DEAL_II_FALLTHROUGH "[[fallthrough]]")
 ELSEIF(DEAL_II_HAVE_ATTRIBUTE_FALLTHROUGH)
@@ -348,6 +344,8 @@ CHECK_CXX_SOURCE_COMPILES(
   "
   DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE)
 
+RESET_CMAKE_REQUIRED()
+
 #
 # Check that we can use feenableexcept through the C++11 header file cfenv:
 #
@@ -456,10 +454,94 @@ ENDIF()
 # functions. This requirement is probabely very conservative in most cases, but
 # it will prevent breaking builds with certain compilers.
 #
+SET(DEAL_II_CONSTEXPR "constexpr")
 IF (DEAL_II_HAVE_CXX14_CONSTEXPR)
-  SET(DEAL_II_CONSTEXPR "constexpr")
 ELSE()
   SET(DEAL_II_CONSTEXPR " ")
 ENDIF()
 
 RESET_CMAKE_REQUIRED()
+
+
+#
+# GCC and some other compilers have an attribute of the form
+# __attribute__((deprecated)) that can be used to make the
+# compiler warn whenever a deprecated function is used. C++14
+# provides a standardized attribute of the form [[deprecated]
+# with the exact same functionality.
+# See if one of these attribute is available.
+#
+# If it is, set the variable DEAL_II_DEPRECATED to its value. If
+# it isn't, set it to an empty string (actually, to a single
+# space, since the empty string causes CMAKE to #undef the
+# variable in config.h), i.e., to something the compiler will
+# ignore
+#
+# - Wolfgang Bangerth, 2012
+#
+
+# first see if the compiler accepts the attribute
+CHECK_CXX_SOURCE_COMPILES(
+  "
+          [[deprecated]] int old_fn ();
+          int old_fn () { return 0; }
+
+          struct [[deprecated]] bob
+          {
+            [[deprecated]] bob(int i);
+            [[deprecated]] void test();
+          };
+
+          enum color
+          {
+            red [[deprecated]]
+          };
+
+          template <int dim>
+          struct foo {};
+          using bar [[deprecated]] = foo<2>;
+
+          int main () {}
+  "
+  DEAL_II_COMPILER_HAS_CXX14_ATTRIBUTE_DEPRECATED
+  )
+
+CHECK_CXX_SOURCE_COMPILES(
+  "
+          __attribute__((deprecated)) int old_fn ();
+          int old_fn () { return 0; }
+
+          struct __attribute__((deprecated)) bob
+          {
+            __attribute__((deprecated)) bob(int i);
+            __attribute__((deprecated)) void test();
+          };
+
+          enum color
+          {
+            red __attribute__((deprecated))
+          };
+
+          template <int dim>
+          struct foo {};
+          using bar __attribute__((deprecated)) = foo<2>;
+
+          int main () {}
+  "
+  DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED
+  )
+
+RESET_CMAKE_REQUIRED()
+
+
+DEAL_II_COMPILER_HAS_CXX14_ATTRIBUTE_DEPRECATED
+IF(DEAL_II_COMPILER_HAS_CXX14_ATTRIBUTE_DEPRECATED)
+  SET(DEAL_II_DEPRECATED "[[deprecated]]")
+ELSEIF(DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED AND NOT DEAL_II_WITH_CUDA)
+  SET(DEAL_II_DEPRECATED "__attribute__((deprecated))")
+ELSE()
+  SET(DEAL_II_DEPRECATED " ")
+ENDIF()
+
+
+RESET_CMAKE_REQUIRED()
index 435f455f1cbd2b403a4a5dc992d0071222b2e073..53b05159e8f29ed8e962acebc7c34231f48a3296 100644 (file)
@@ -30,7 +30,6 @@
 #   DEAL_II_COMPILER_HAS_ATTRIBUTE_PRETTY_FUNCTION
 #   DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED
 #   DEAL_II_COMPILER_HAS_ATTRIBUTE_ALWAYS_INLINE
-#   DEAL_II_DEPRECATED
 #   DEAL_II_ALWAYS_INLINE
 #   DEAL_II_RESTRICT
 #   DEAL_II_COMPILER_HAS_DIAGNOSTIC_PRAGMA
 #
 
 #
-# A couple of test results depend on compiler flags and the C++ mode. Rerun
-# these tests if necessary
+# A couple of test results depend on compiler flags and the C++ mode.
+# Nota Bene: If your test depends on the value of compile flags set in
+# ${DEAL_II_CXX_FLAGS} it is probably a language feature and should go into
+# check_01_cxx_features.cmake
 #
 
-UNSET_IF_CHANGED(CHECK_CXX_FEATURES_FLAGS_SAVED
-  "${CMAKE_REQUIRED_FLAGS}${DEAL_II_CXX_VERSION_FLAG}${DEAL_II_WITH_CXX14}${DEAL_II_WITH_CXX17}"
-  DEAL_II_COMPILER_HAS_CXX14_ATTRIBUTE_DEPRECATED
-  DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED
-  )
-
-#
-# MSVC needs different compiler flags to turn warnings into errors
-# additionally a suitable exception handling model is required
-#
-IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
-  SET(_werror_flag "/WX /EHsc")
-ELSE()
-  SET(_werror_flag "-Werror")
-ENDIF()
 
 #
 # Check whether the compiler allows to use arithmetic operations
@@ -126,8 +112,7 @@ CHECK_CXX_COMPILER_BUG(
 #
 # - Matthias Maier, rewritten 2012
 #
-IF(NOT(CMAKE_CXX_COMPILER_ID MATCHES "Intel" AND
-       DEAL_II_HAVE_CXX14_CONSTEXPR))
+IF(NOT CMAKE_CXX_COMPILER_ID MATCHES "Intel")
   CHECK_CXX_SOURCE_COMPILES(
     "
     bool f() { return true; }
@@ -253,7 +238,6 @@ IF(NOT DEAL_II_COMPILER_HAS_ATTRIBUTE_PRETTY_FUNCTION)
   ELSE()
     SET(__PRETTY_FUNCTION__ "\"(not available)\"")
   ENDIF()
-
 ENDIF()
 
 
@@ -288,96 +272,6 @@ IF( (NOT CMAKE_SYSTEM_NAME MATCHES "CYGWIN") AND
 ENDIF()
 
 
-#
-# GCC and some other compilers have an attribute of the form
-# __attribute__((deprecated)) that can be used to make the
-# compiler warn whenever a deprecated function is used. C++14
-# provides a standardized attribute of the form [[deprecated]
-# with the exact same functionality.
-# See if one of these attribute is available.
-#
-# If it is, set the variable DEAL_II_DEPRECATED to its value. If
-# it isn't, set it to an empty string (actually, to a single
-# space, since the empty string causes CMAKE to #undef the
-# variable in config.h), i.e., to something the compiler will
-# ignore
-#
-# - Wolfgang Bangerth, 2012
-#
-
-# Some compilers swallow the deprecation attribute, but emit a warning saying
-# that it is actually not supported such as:
-# "warning: use of the 'deprecated' attribute is a C++14 extension" (clang in c++11 mode)
-# "warning #1292: unknown attribute "deprecated"" (icc)
-# Hence, we treat warnings as errors:
-ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_FLAGS}")
-ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${_werror_flag}")
-IF(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
-  ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Wno-unused-command-line-argument")
-ENDIF()
-
-# first see if the compiler accepts the attribute
-CHECK_CXX_SOURCE_COMPILES(
-  "
-          [[deprecated]] int old_fn ();
-          int old_fn () { return 0; }
-
-          struct [[deprecated]] bob
-          {
-            [[deprecated]] bob(int i);
-            [[deprecated]] void test();
-          };
-
-          enum color
-          {
-            red [[deprecated]]
-          };
-
-          template <int dim>
-          struct foo {};
-          using bar [[deprecated]] = foo<2>;
-
-          int main () {}
-  "
-  DEAL_II_COMPILER_HAS_CXX14_ATTRIBUTE_DEPRECATED
-  )
-
-CHECK_CXX_SOURCE_COMPILES(
-  "
-          __attribute__((deprecated)) int old_fn ();
-          int old_fn () { return 0; }
-
-          struct __attribute__((deprecated)) bob
-          {
-            __attribute__((deprecated)) bob(int i);
-            __attribute__((deprecated)) void test();
-          };
-
-          enum color
-          {
-            red __attribute__((deprecated))
-          };
-
-          template <int dim>
-          struct foo {};
-          using bar __attribute__((deprecated)) = foo<2>;
-
-          int main () {}
-  "
-  DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED
-  )
-
-RESET_CMAKE_REQUIRED()
-
-IF(DEAL_II_COMPILER_HAS_CXX14_ATTRIBUTE_DEPRECATED)
-  SET(DEAL_II_DEPRECATED "[[deprecated]]")
-ELSEIF(DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED AND NOT DEAL_II_WITH_CUDA)
-  SET(DEAL_II_DEPRECATED "__attribute__((deprecated))")
-ELSE()
-  SET(DEAL_II_DEPRECATED " ")
-ENDIF()
-
-
 #
 # Do a similar check with the always_inline attribute on functions.
 #
@@ -395,6 +289,7 @@ ELSE()
   SET(DEAL_II_ALWAYS_INLINE " ")
 ENDIF()
 
+
 #
 # Check whether the compiler understands the __restrict keyword.
 #
index 48746a32098610c1db5a9ee0164aa899a3b600a2..550bb8735186ab6ab6d4e2361119a2b5d4010915 100644 (file)
@@ -196,6 +196,7 @@ SET(_files
 FOREACH(_file ${_files})
   FILE(APPEND ${_file} "\n\n#\n# Feature configuration:\n#\n\n")
   FILE(APPEND ${_file} "SET(DEAL_II_WITH_CXX11 ON)\n")
+  FILE(APPEND ${_file} "SET(DEAL_II_WITH_CXX14 ON)\n")
 ENDFOREACH()
 
 GET_CMAKE_PROPERTY(_res VARIABLES)
index 324d1727e52964b4812e61a9dafae187892bc6f6..788ef1c6ec7710ec4f750932bb2106614f0bd1cc 100644 (file)
@@ -69,24 +69,23 @@ MACRO(FEATURE_CUDA_FIND_EXTERNAL var)
     # CUDA Toolkit 9 and CUDA Toolkit 10 are incompatible with C++17.
     # Make sure that deal.II is configured appropriately
     #
-    MACRO(_cuda_ensure_feature_off _version _feature)
+    MACRO(_cuda_ensure_feature_off _version _cpp_version_bad _cpp_version_good)
       IF(${CUDA_VERSION_MAJOR} EQUAL ${_version})
-        IF(${_feature})
+        IF(${DEAL_II_HAVE_CXX${_cpp_version_bad}})
           SET(${var} FALSE)
           MESSAGE(STATUS "CUDA ${_version} requires ${_feature} to be set to off.")
           SET(CUDA_ADDITIONAL_ERROR_STRING
             ${CUDA_ADDITIONAL_ERROR_STRING}
-            "CUDA ${_version} is not compatible with the C++ standard\n"
-            "enabled by ${_feature}.\n"
-            "Please disable ${_feature}, e.g. by reconfiguring with\n"
-            "  cmake -D${_feature}=OFF .\n"
+            "CUDA ${_version} is not compatible with the C++${_cpp_version_bad} standard.\n"
+            "Please explicitly set the standard version to C++${_cpp_version_good}, e.g. by reconfiguring with\n"
+            "  cmake -DDEAL_II_CXX_FLAGS=\"-std=c++${_cpp_version_good}\" ."
             )
         ENDIF()
       ENDIF()
     ENDMACRO()
-    _cuda_ensure_feature_off(9 DEAL_II_WITH_CXX17)
-    _cuda_ensure_feature_off(10 DEAL_II_WITH_CXX17)
 
+    _cuda_ensure_feature_off(9 17 14)
+    _cuda_ensure_feature_off(10 17 14)
 
     IF("${DEAL_II_CUDA_FLAGS_SAVED}" MATCHES "-arch[ ]*sm_([0-9]*)")
       SET(CUDA_COMPUTE_CAPABILITY "${CMAKE_MATCH_1}")
index 88600e0f204f6178126db6a1452b56aa930a95d7..63aa969d151d52f85e8825a41fc8f16728ba84ff 100644 (file)
@@ -98,7 +98,7 @@ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-psabi")
 # Disable warnings regarding improper direct memory access
 # if compiling without C++17 support
 #
-IF(NOT DEAL_II_WITH_CXX17)
+IF(NOT DEAL_II_HAVE_CXX17)
   ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wno-class-memaccess")
 ENDIF()
 
index 269776f8264be1cddf3369f0de12c05d29c840c5..4dbecd2c0633031aaf8b5f54d527a40a3fd0dba5 100644 (file)
@@ -40,8 +40,6 @@
 #cmakedefine DEAL_II_WITH_ASSIMP
 #cmakedefine DEAL_II_WITH_COMPLEX_VALUES
 #cmakedefine DEAL_II_WITH_CUDA
-#cmakedefine DEAL_II_WITH_CXX14
-#cmakedefine DEAL_II_WITH_CXX17
 #cmakedefine DEAL_II_WITH_GINKGO
 #cmakedefine DEAL_II_WITH_GSL
 #cmakedefine DEAL_II_WITH_GMSH
@@ -66,8 +64,9 @@
 #cmakedefine DEAL_II_WITH_UMFPACK
 #cmakedefine DEAL_II_WITH_ZLIB
 
-// defined for backwards compatibility with pre-C++11
+// defined for backwards compatibility with older deal.II versions
 #define DEAL_II_WITH_CXX11
+#define DEAL_II_WITH_CXX14
 
 /***********************************************************************
  * Compiler bugs:
  * For documentation see cmake/checks/check_01_cxx_features.cmake
  */
 
+#cmakedefine DEAL_II_HAVE_CXX17
+
 #cmakedefine DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE
 #cmakedefine DEAL_II_HAVE_CXX14_CONSTEXPR
 #cmakedefine DEAL_II_HAVE_FP_EXCEPTIONS

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.