]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Allow configuring with CMAKE_CXX_STANDARD=23
authorDaniel Arndt <arndtd@ornl.gov>
Thu, 20 Jul 2023 20:36:52 +0000 (16:36 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Thu, 20 Jul 2023 20:36:52 +0000 (16:36 -0400)
cmake/checks/check_01_cxx_features.cmake
cmake/setup_write_config.cmake

index b550f6b156783c026d599e7d7e33efa8eac67828..e54e413356bf850be1a023cac56bcf8786ed71fb 100644 (file)
@@ -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 <version>
+
+    #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)
index f4bc2f3d94f093aa556e1c37c1b63375d7aceceb..0f506c92a05f8070e0ebd2e1e6a445dfeb991a50 100644 (file)
@@ -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")

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.