File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ include(compiler_warnings.cmake)
22find_package (Catch2 3 REQUIRED)
33include (CTest)
44include (Catch)
5+ include (CheckSourceCompiles)
56
67set (cxx_17_files
78 ${CMAKE_CURRENT_SOURCE_DIR} /add_noexcept.cpp
@@ -35,6 +36,20 @@ set(cxx_23_files
3536 ${CMAKE_CURRENT_SOURCE_DIR} /traced_error.cpp
3637)
3738
39+ block(SCOPE_FOR VARIABLES )
40+ if (MSVC )
41+ set (CMAKE_REQUIRED_FLAGS /Zc:__cplusplus /std:c++latest)
42+ else ()
43+ set (CMAKE_REQUIRED_FLAGS -std=c++23)
44+ endif ()
45+ check_source_compiles(CXX "
46+ int main(void){
47+ static_assert(__cplusplus >= 202302L);
48+ }
49+ "
50+ HAS_CXX_23)
51+ endblock()
52+
3853function (setup_target target )
3954 target_link_libraries (${target} PRIVATE UT::all )
4055 set_target_warnings(${target} )
@@ -59,7 +74,11 @@ target_compile_features(libut_tests_23 PUBLIC cxx_std_23)
5974
6075setup_target(libut_tests_17)
6176setup_target(libut_tests_20)
62- setup_target(libut_tests_23)
63- if (NOT MSVC )
64- target_link_libraries (libut_tests_23 PUBLIC stdc++exp)
77+ if (HAS_CXX_23)
78+ setup_target(libut_tests_23)
79+ if (NOT MSVC )
80+ target_link_libraries (libut_tests_23 PUBLIC stdc++exp)
81+ endif ()
82+ else ()
83+ message (WARNING "${CMAKE_CXX_COMPILER} does not support C++23, tests will not run" )
6584endif ()
You can’t perform that action at this time.
0 commit comments