Skip to content

Commit

Permalink
Merge pull request #15772 from masterleinad/support_cmake_cxx_standar…
Browse files Browse the repository at this point in the history
…d_23
  • Loading branch information
masterleinad committed Jul 21, 2023
2 parents dcce8d6 + 5fd0449 commit 5a4ffdb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
41 changes: 41 additions & 0 deletions cmake/checks/check_01_cxx_features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,45 @@ 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
struct Dummy {
static void operator()() {}
};
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.
#
Expand Down Expand Up @@ -334,6 +373,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)
Expand Down
4 changes: 3 additions & 1 deletion cmake/setup_write_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 5a4ffdb

Please sign in to comment.