Skip to content

Commit 7aa41ed

Browse files
authored
CMake: Condition core_name tests on CMake version (#224)
As those tests require C++20 only compile them with CMake 3.12+ to be able to use `cxx_std_20`
1 parent 7509049 commit 7aa41ed

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

test/CMakeLists.txt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ foreach (testsourcefile ${CORE_RUN_FILES})
1616
add_dependencies(tests pfr_core_${testname})
1717
endforeach()
1818

19-
file(GLOB CORE_NAME_RUN_FILES "core_name/run/*.cpp")
20-
foreach (testsourcefile ${CORE_NAME_RUN_FILES})
21-
get_filename_component(testname ${testsourcefile} NAME_WE)
22-
add_executable(pfr_corename_${testname} ${testsourcefile})
23-
target_compile_features(pfr_corename_${testname} PUBLIC cxx_std_20)
24-
target_link_libraries(pfr_corename_${testname} Boost::pfr Boost::core Boost::container_hash)
25-
target_include_directories(pfr_corename_${testname} PRIVATE ../../../)
26-
add_test(NAME pfr_corename_${testname} COMMAND pfr_corename_${testname})
27-
add_dependencies(tests pfr_corename_${testname})
28-
endforeach()
19+
if(CMAKE_VERSION VERSION_LESS 3.12)
20+
message(AUTHOR_WARNING "Disabling core_name tests as CMake version 3.12+ is required but using ${CMAKE_VERSION}")
21+
else()
22+
file(GLOB CORE_NAME_RUN_FILES "core_name/run/*.cpp")
23+
foreach (testsourcefile ${CORE_NAME_RUN_FILES})
24+
get_filename_component(testname ${testsourcefile} NAME_WE)
25+
add_executable(pfr_corename_${testname} ${testsourcefile})
26+
target_compile_features(pfr_corename_${testname} PUBLIC cxx_std_20)
27+
target_link_libraries(pfr_corename_${testname} Boost::pfr Boost::core Boost::container_hash)
28+
target_include_directories(pfr_corename_${testname} PRIVATE ../../../)
29+
add_test(NAME pfr_corename_${testname} COMMAND pfr_corename_${testname})
30+
add_dependencies(tests pfr_corename_${testname})
31+
endforeach()
32+
endif()

0 commit comments

Comments
 (0)