From 7aa41ed4f5aaa7e52570030e7b28f28cede4f9c1 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 28 Oct 2025 17:40:55 +0100 Subject: [PATCH] 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` --- test/CMakeLists.txt | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bd02f8f..f428a8f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,13 +16,17 @@ foreach (testsourcefile ${CORE_RUN_FILES}) add_dependencies(tests pfr_core_${testname}) endforeach() -file(GLOB CORE_NAME_RUN_FILES "core_name/run/*.cpp") -foreach (testsourcefile ${CORE_NAME_RUN_FILES}) - get_filename_component(testname ${testsourcefile} NAME_WE) - add_executable(pfr_corename_${testname} ${testsourcefile}) - target_compile_features(pfr_corename_${testname} PUBLIC cxx_std_20) - target_link_libraries(pfr_corename_${testname} Boost::pfr Boost::core Boost::container_hash) - target_include_directories(pfr_corename_${testname} PRIVATE ../../../) - add_test(NAME pfr_corename_${testname} COMMAND pfr_corename_${testname}) - add_dependencies(tests pfr_corename_${testname}) -endforeach() +if(CMAKE_VERSION VERSION_LESS 3.12) + message(AUTHOR_WARNING "Disabling core_name tests as CMake version 3.12+ is required but using ${CMAKE_VERSION}") +else() + file(GLOB CORE_NAME_RUN_FILES "core_name/run/*.cpp") + foreach (testsourcefile ${CORE_NAME_RUN_FILES}) + get_filename_component(testname ${testsourcefile} NAME_WE) + add_executable(pfr_corename_${testname} ${testsourcefile}) + target_compile_features(pfr_corename_${testname} PUBLIC cxx_std_20) + target_link_libraries(pfr_corename_${testname} Boost::pfr Boost::core Boost::container_hash) + target_include_directories(pfr_corename_${testname} PRIVATE ../../../) + add_test(NAME pfr_corename_${testname} COMMAND pfr_corename_${testname}) + add_dependencies(tests pfr_corename_${testname}) + endforeach() +endif()