From 46a98937168a8f5828cc87dbf5020ad3d22352c3 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Mon, 5 Oct 2026 09:27:14 +0200 Subject: [PATCH] test: compile public C++20 headers independently --- test/CMakeLists.txt | 16 ++++++++++++++-- test/public_headers_cpp20.cpp | 17 ----------------- 2 files changed, 14 insertions(+), 19 deletions(-) delete mode 100644 test/public_headers_cpp20.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c44860c63..63f25ce05 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -204,10 +204,22 @@ target_link_libraries(odr_test gtest_add_tests(TARGET odr_test) -# Holds the public headers to C++20. Not a gtest: it compiles or it does not. -add_library(odr_public_headers_cpp20 OBJECT "public_headers_cpp20.cpp") +# Compile each installed public header independently as a C++20 consumer. +file(GLOB ODR_PUBLIC_HEADERS CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/odr/*.hpp") +set(ODR_PUBLIC_HEADER_TESTS) +foreach (header IN LISTS ODR_PUBLIC_HEADERS) + get_filename_component(name "${header}" NAME) + if (name STREQUAL "http_server.hpp" AND NOT ODR_WITH_HTTP_SERVER) + continue() + endif () + set(source "${CMAKE_CURRENT_BINARY_DIR}/public_headers_cpp20/${name}.cpp") + file(GENERATE OUTPUT "${source}" CONTENT "#include \n") + list(APPEND ODR_PUBLIC_HEADER_TESTS "${source}") +endforeach () +add_library(odr_public_headers_cpp20 OBJECT ${ODR_PUBLIC_HEADER_TESTS}) target_link_libraries(odr_public_headers_cpp20 PRIVATE odr) set_target_properties(odr_public_headers_cpp20 PROPERTIES + UNITY_BUILD OFF CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF) diff --git a/test/public_headers_cpp20.cpp b/test/public_headers_cpp20.cpp deleted file mode 100644 index 954c0d9a9..000000000 --- a/test/public_headers_cpp20.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Every public header, compiled as a C++20 consumer sees them. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include