Skip to content

Commit 92525c2

Browse files
committed
gate some tests behind C++17
1 parent 0144d18 commit 92525c2

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ if(MDSPAN_ENABLE_EXAMPLES)
148148
endif()
149149

150150
if(MDSPAN_ENABLE_BENCHMARKS)
151-
if(NOT MDSPAN_CXX_STANDARD STREQUAL "14" AND NOT MDSPAN_CXX_STANDARD STREQUAL "23")
151+
if("cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
152152
add_subdirectory(benchmarks)
153153
else()
154154
MESSAGE(FATAL_ERROR "Benchmarks are not available in C++14 or C++23 mode. Turn MDSPAN_ENABLE_BENCHMARKS OFF or use C++17 or C++20.")

benchmarks/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function(mdspan_add_benchmark EXENAME)
77
)
88
# Set flag to build with parenthesis enabled
99
target_compile_definitions(${EXENAME} PRIVATE MDSPAN_USE_PAREN_OPERATOR=1)
10+
target_compile_features(${EXENAME} PRIVATE cxx_std_17)
1011
endfunction()
1112

1213
if(MDSPAN_USE_SYSTEM_BENCHMARK)
@@ -81,6 +82,7 @@ function(mdspan_add_openmp_benchmark EXENAME)
8182
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/benchmarks>
8283
)
8384
target_compile_definitions(${EXENAME} PRIVATE MDSPAN_USE_PAREN_OPERATOR=1)
85+
target_compile_features(${EXENAME} PRIVATE cxx_std_17)
8486
else()
8587
message(WARNING "Not adding target ${EXENAME} because OpenMP was not found")
8688
endif()

compilation_tests/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ if(NOT MDSPAN_ENABLE_CUDA)
2121
add_compilation_test(ctest_compressed_pair_layout)
2222
endif()
2323
add_compilation_test(ctest_constexpr_dereference)
24-
if(NOT CMAKE_CXX_STANDARD STREQUAL "14")
25-
add_compilation_test(ctest_constexpr_submdspan)
24+
if("cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
25+
add_compilation_test(ctest_constexpr_submdspan)
26+
target_compile_features(ctest_constexpr_submdspan PRIVATE cxx_std_17)
2627
endif()
2728
add_compilation_test(ctest_constexpr_layouts)
2829
add_compilation_test(ctest_namespace_std)

0 commit comments

Comments
 (0)