fix(build): keep counter instrumentation out of the installed release library
The linux-release preset inherited PLOT_BUILD_TESTS=ON, so the release build compiled the pyramid cover/merge and ring upload/wait/slot counters into libplot_core.a and cmake --install shipped them. Set PLOT_BUILD_TESTS=OFF in the preset; the suite keeps running in linux-debug and linux-asan, which are unchanged. Also pin the two header properties the plan calls Global Constraints and that nothing guarded: every header under include/plot/ compiles standalone, and include/plot/plot.hpp includes every public one. tests/CMakeLists.txt globs the headers at configure time (CONFIGURE_DEPENDS) and generates one TU per header plus an umbrella TU that constructs Plot, Renderer, data::StreamSeries and input::Controller; a ctest entry builds the header TUs and runs the umbrella, and cmake/plot_umbrella_check.cmake fails configure and ctest when a public header is missing from the umbrella.
This commit is contained in:
1 parent
0972903d27
commit
f363523195
3 files changed
+149
No files matched your search
@@ -85,3 +85,74 @@ if(PLOT_ASAN_ENABLED)
|
||||
set_tests_properties(plot_tests PROPERTIES ENVIRONMENT
|
||||
"ASAN_OPTIONS=detect_leaks=1:print_suppressions=1:suppressions=${CMAKE_SOURCE_DIR}/cmake/plot_asan_suppressions.txt")
|
||||
endif()
|
||||
|
||||
# --- public headers: standalone compilation and umbrella coverage -------------
|
||||
#
|
||||
# The plan's Global Constraints require every header under include/plot/ to
|
||||
# compile standalone, and include/plot/plot.hpp to include every public one
|
||||
# (never an adapter). Both were verified by hand and nothing kept them true, so
|
||||
# a header added later could break either silently. These targets make the build
|
||||
# enforce both and the ctest entries below make the suite fail when the checks
|
||||
# do. The header list is globbed at configure time (CONFIGURE_DEPENDS, so adding
|
||||
# or removing a header re-globs) -- a hand-kept list would defeat the point.
|
||||
file(GLOB_RECURSE plot_public_headers CONFIGURE_DEPENDS
|
||||
RELATIVE "${CMAKE_SOURCE_DIR}/include"
|
||||
"${CMAKE_SOURCE_DIR}/include/plot/*.hpp")
|
||||
list(SORT plot_public_headers)
|
||||
|
||||
# One generated TU per header, each holding only that header's #include. An
|
||||
# OBJECT library: this is a compile check, with no link step, so any header that
|
||||
# needs something it does not itself include fails the build here.
|
||||
set(plot_header_check_sources "")
|
||||
foreach(plot_header IN LISTS plot_public_headers)
|
||||
string(MAKE_C_IDENTIFIER "${plot_header}" plot_header_slug)
|
||||
set(plot_header_check_source "${CMAKE_CURRENT_BINARY_DIR}/header_checks/${plot_header_slug}.cpp")
|
||||
set(plot_header_check_content
|
||||
"// Generated by tests/CMakeLists.txt: <${plot_header}> must compile on its own.\n#include <${plot_header}>\n")
|
||||
file(GENERATE OUTPUT "${plot_header_check_source}" CONTENT "${plot_header_check_content}")
|
||||
list(APPEND plot_header_check_sources "${plot_header_check_source}")
|
||||
endforeach()
|
||||
|
||||
add_library(plot_header_self_containment OBJECT ${plot_header_check_sources})
|
||||
target_link_libraries(plot_header_self_containment PRIVATE plot::core)
|
||||
plot_apply_warnings(plot_header_self_containment)
|
||||
|
||||
# The umbrella on its own: the generated TU includes only <plot/plot.hpp> and
|
||||
# constructs one of each layer's entry type, so an umbrella that misses a header
|
||||
# -- or that is unusable without further includes -- fails to build. The test
|
||||
# runs the linked binary, so a build that produced nothing usable still fails.
|
||||
set(plot_umbrella_check_source "${CMAKE_CURRENT_BINARY_DIR}/umbrella_check.cpp")
|
||||
file(GENERATE OUTPUT "${plot_umbrella_check_source}" CONTENT
|
||||
"// Generated by tests/CMakeLists.txt: the umbrella must be usable by itself.
|
||||
#include <plot/plot.hpp>
|
||||
|
||||
int main() {
|
||||
plot::Plot plot;
|
||||
plot::Renderer renderer;
|
||||
plot::data::StreamSeries series(16, 0.0, 1.0);
|
||||
plot::input::Controller controller(plot);
|
||||
(void)renderer;
|
||||
(void)series;
|
||||
(void)controller;
|
||||
return 0;
|
||||
}
|
||||
")
|
||||
add_executable(plot_umbrella_check "${plot_umbrella_check_source}")
|
||||
target_link_libraries(plot_umbrella_check PRIVATE plot::core)
|
||||
plot_apply_warnings(plot_umbrella_check)
|
||||
|
||||
# Coverage check on the umbrella. Included here so a public header missing from
|
||||
# plot.hpp stops the configure; the ctest entry below runs the same script again
|
||||
# so the check is also a visible test.
|
||||
set(PLOT_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include")
|
||||
set(PLOT_UMBRELLA "${CMAKE_SOURCE_DIR}/include/plot/plot.hpp")
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/plot_umbrella_check.cmake")
|
||||
|
||||
add_test(NAME plot_headers_self_contained
|
||||
COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}" --target plot_header_self_containment)
|
||||
add_test(NAME plot_umbrella_covers_public_headers
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DPLOT_INCLUDE_DIR=${CMAKE_SOURCE_DIR}/include
|
||||
-DPLOT_UMBRELLA=${CMAKE_SOURCE_DIR}/include/plot/plot.hpp
|
||||
-P "${CMAKE_SOURCE_DIR}/cmake/plot_umbrella_check.cmake")
|
||||
add_test(NAME plot_umbrella_check COMMAND plot_umbrella_check)
|
||||
Reference in new issue
Block a user