From: Daniel Arndt Date: Thu, 20 Jul 2023 20:36:52 +0000 (-0400) Subject: Allow configuring with CMAKE_CXX_STANDARD=23 X-Git-Tag: relicensing~664^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=178b6afd3a5de4ff775e20ddfaa6c107480f15a2;p=dealii.git Allow configuring with CMAKE_CXX_STANDARD=23 --- diff --git a/cmake/checks/check_01_cxx_features.cmake b/cmake/checks/check_01_cxx_features.cmake index b550f6b156..e54e413356 100644 --- a/cmake/checks/check_01_cxx_features.cmake +++ b/cmake/checks/check_01_cxx_features.cmake @@ -50,6 +50,41 @@ macro(_set_up_cmake_required) endmacro() +# +# Wrap the following checks into a macro to make it easier to rerun them. +# +macro(_test_cxx23_support) + unset_if_changed(CHECK_CXX23_FEATURES_FLAGS_SAVED + "${CMAKE_REQUIRED_FLAGS}${CMAKE_CXX_STANDARD}" + DEAL_II_HAVE_CXX23_FEATURES + ) + + # Strictly speaking "202100L" indicates support for a preliminary version + # of the C++23 standard (which will have "202302L" when finalized). gcc-13 + # exports this version number when configured with C++23 support. + CHECK_CXX_SOURCE_COMPILES( + " + #include + + #if __cplusplus < 202100L && !defined(_MSC_VER) && !defined(__INTEL_COMPILER) + # error \"insufficient support for C++23\" + #endif + + int main() {} + " + DEAL_II_HAVE_CXX23_FEATURES) + + if(DEAL_II_HAVE_CXX23_FEATURES) + message(STATUS "C++23 support is enabled.") + set(DEAL_II_HAVE_CXX23 TRUE) + set(_cxx_standard 23) + else() + message(STATUS "C++23 support is disabled.") + set(DEAL_II_HAVE_CXX23 FALSE) + endif() +endmacro() + + # # Wrap the following checks into a macro to make it easier to rerun them. # @@ -334,6 +369,8 @@ endif() _test_cxx20_support() +_test_cxx23_support() + set_if_empty(CMAKE_CXX_STANDARD "${_cxx_standard}") set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/cmake/setup_write_config.cmake b/cmake/setup_write_config.cmake index f4bc2f3d94..0f506c92a0 100644 --- a/cmake/setup_write_config.cmake +++ b/cmake/setup_write_config.cmake @@ -76,7 +76,9 @@ if(CMAKE_Fortran_COMPILER_WORKS) endif() _detailed("# CMAKE_GENERATOR: ${CMAKE_GENERATOR}\n") -if(DEAL_II_HAVE_CXX20) +if(DEAL_II_HAVE_CXX23) + _both("# C++ language standard: C++23\n") +elseif(DEAL_II_HAVE_CXX20) _both("# C++ language standard: C++20\n") elseif(DEAL_II_HAVE_CXX17) _both("# C++ language standard: C++17\n")