# 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
# #
########################################################################
+
+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
#
# 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(
"
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)
"
DEAL_II_HAVE_CXX11_IS_TRIVIALLY_COPYABLE)
+RESET_CMAKE_REQUIRED()
+
#
# Check that we can use feenableexcept through the C++11 header file cfenv:
#
# 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()
# 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
#
# - 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; }
ELSE()
SET(__PRETTY_FUNCTION__ "\"(not available)\"")
ENDIF()
-
ENDIF()
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.
#
SET(DEAL_II_ALWAYS_INLINE " ")
ENDIF()
+
#
# Check whether the compiler understands the __restrict keyword.
#
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)
# 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}")
# 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()
#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
#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