From: Matthias Maier Date: Fri, 22 May 2020 02:34:35 +0000 (-0500) Subject: update configuration X-Git-Tag: v9.3.0-rc1~1575^2~16 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=297cb0b6422816fd44dca18822bf66f9542263fe;p=dealii.git update configuration --- diff --git a/cmake/checks/check_01_cxx_features.cmake b/cmake/checks/check_01_cxx_features.cmake index 4205ffe002..151e50b65a 100644 --- a/cmake/checks/check_01_cxx_features.cmake +++ b/cmake/checks/check_01_cxx_features.cmake @@ -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 + 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 + 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() diff --git a/cmake/checks/check_02_compiler_features.cmake b/cmake/checks/check_02_compiler_features.cmake index 435f455f1c..53b05159e8 100644 --- a/cmake/checks/check_02_compiler_features.cmake +++ b/cmake/checks/check_02_compiler_features.cmake @@ -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 @@ -38,25 +37,12 @@ # # -# 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 - 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 - 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. # diff --git a/cmake/config/CMakeLists.txt b/cmake/config/CMakeLists.txt index 48746a3209..550bb87351 100644 --- a/cmake/config/CMakeLists.txt +++ b/cmake/config/CMakeLists.txt @@ -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) diff --git a/cmake/configure/configure_1_cuda.cmake b/cmake/configure/configure_1_cuda.cmake index 324d1727e5..788ef1c6ec 100644 --- a/cmake/configure/configure_1_cuda.cmake +++ b/cmake/configure/configure_1_cuda.cmake @@ -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}") diff --git a/cmake/setup_compiler_flags_gnu.cmake b/cmake/setup_compiler_flags_gnu.cmake index 88600e0f20..63aa969d15 100644 --- a/cmake/setup_compiler_flags_gnu.cmake +++ b/cmake/setup_compiler_flags_gnu.cmake @@ -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() diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index 269776f826..4dbecd2c06 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -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: @@ -138,6 +137,8 @@ * 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