Skip to content

Commit

Permalink
Always do single includes.
Browse files Browse the repository at this point in the history
They're cheap, reliable and valuable, no point skipping them.
  • Loading branch information
1uc committed May 18, 2024
1 parent ef323aa commit 8029f34
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,35 @@ if(HDF5_IS_PARALLEL)
set(_CATCH_DISCOVER_TESTS_SCRIPT "${original_catch_script}")
endif()

if(HIGHFIVE_TEST_SINGLE_INCLUDES)
file(GLOB public_headers LIST_DIRECTORIES false RELATIVE ${PROJECT_SOURCE_DIR}/include CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/include/highfive/*.hpp)
foreach(PUBLIC_HEADER ${public_headers})
if(PUBLIC_HEADER STREQUAL "highfive/span.hpp" AND NOT HIGHFIVE_TEST_SPAN)
continue()
endif()
# Test that each public header is self-sufficient. This is done by
# creating a file for each header, that only includes the header. The
# test succeeds if it compiles.
file(GLOB public_headers LIST_DIRECTORIES false RELATIVE ${PROJECT_SOURCE_DIR}/include CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/include/highfive/*.hpp)
foreach(PUBLIC_HEADER ${public_headers})
if(PUBLIC_HEADER STREQUAL "highfive/span.hpp" AND NOT HIGHFIVE_TEST_SPAN)
continue()
endif()

if(PUBLIC_HEADER STREQUAL "highfive/boost.hpp" AND NOT HIGHFIVE_TEST_BOOST)
continue()
endif()
if(PUBLIC_HEADER STREQUAL "highfive/boost.hpp" AND NOT HIGHFIVE_TEST_BOOST)
continue()
endif()

if(PUBLIC_HEADER STREQUAL "highfive/half_float.hpp" AND NOT HIGHFIVE_TEST_HALF_FLOAT)
continue()
endif()
if(PUBLIC_HEADER STREQUAL "highfive/half_float.hpp" AND NOT HIGHFIVE_TEST_HALF_FLOAT)
continue()
endif()

if(PUBLIC_HEADER STREQUAL "highfive/eigen.hpp" AND NOT HIGHFIVE_TEST_EIGEN)
continue()
endif()
if(PUBLIC_HEADER STREQUAL "highfive/eigen.hpp" AND NOT HIGHFIVE_TEST_EIGEN)
continue()
endif()

get_filename_component(CLASS_NAME ${PUBLIC_HEADER} NAME_WE)
configure_file(tests_import_public_headers.cpp "tests_${CLASS_NAME}.cpp" @ONLY)
add_executable("tests_include_${CLASS_NAME}" "${CMAKE_CURRENT_BINARY_DIR}/tests_${CLASS_NAME}.cpp")
target_link_libraries(
"tests_include_${CLASS_NAME}" PUBLIC
HighFive
HighFiveWarnings
HighFiveFlags
HighFiveOptionalDependencies
)
endforeach()
endif()
get_filename_component(CLASS_NAME ${PUBLIC_HEADER} NAME_WE)
configure_file(tests_import_public_headers.cpp "tests_${CLASS_NAME}.cpp" @ONLY)
add_executable("tests_include_${CLASS_NAME}" "${CMAKE_CURRENT_BINARY_DIR}/tests_${CLASS_NAME}.cpp")
target_link_libraries(
"tests_include_${CLASS_NAME}" PUBLIC
HighFive
HighFiveWarnings
HighFiveFlags
HighFiveOptionalDependencies
)
endforeach()

0 comments on commit 8029f34

Please sign in to comment.