feat(build): install/export rules, umbrella header, verified consumer

This commit is contained in:
Martino Ferrari committed 2026-09-28 03:17:20 +02:00
1 parent 377cca8e9b
commit 0972903d27
11 files changed
+333 -7

No files matched your search

+20 -1
View File
@@ -19,9 +19,19 @@ endif()
add_library(plot_qt6 STATIC qt_plot_widget.cpp qt_plot_widget.hpp)
add_library(plot::qt6 ALIAS plot_qt6)
# The installed tree names it plot::qt6, like the build tree (see plot_core's).
set_target_properties(plot_qt6 PROPERTIES EXPORT_NAME qt6)
# The public include root is `adapters/`, so the header is reached as
# <qt6/qt_plot_widget.hpp> -- the toolkit's name first, like every other adapter's.
target_include_directories(plot_qt6 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
# The build interface is that root; the install one is the prefix's `include`,
# where both headers are installed as <qt6/...> -- the same spelling. The pointer
# anchor in qt_pointer.hpp is internal API, but it still ships: the widget's header
# includes it, so a consumer that gets one without the other does not compile.
target_include_directories(plot_qt6 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>)
# Qt is PUBLIC, unlike GLFW and ImGui: the widget's header derives from
# QOpenGLWidget, so a consumer needs Qt's headers and libraries to use it at all.
target_link_libraries(plot_qt6 PUBLIC
@@ -35,3 +45,12 @@ target_link_libraries(plot_qt6 PUBLIC
# Qt class in it, and AUTOMOC scans every source of a target it is set on.
set_target_properties(plot_qt6 PROPERTIES AUTOMOC ON)
plot_apply_warnings(plot_qt6)
# Qt is a system SDK found with find_package() -- a missing Qt6 is a configure
# error above, never a fetch -- so the installed config file can re-find it with
# the same components and the widget's public Qt link interface is satisfiable.
plot_record_adapter_export(plot_qt6 TRUE "Qt6 was resolved by find_package"
"find_dependency(Qt6 COMPONENTS Core Gui Widgets OpenGLWidgets)\n")
if(PLOT_INSTALL)
install(FILES qt_plot_widget.hpp qt_pointer.hpp DESTINATION include/qt6)
endif()