feat(build): install/export rules, umbrella header, verified consumer
This commit is contained in:
1 parent
377cca8e9b
commit
0972903d27
11 files changed
+333
-7
No files matched your search
@@ -22,13 +22,33 @@ endif()
|
||||
|
||||
add_library(plot_gtk4 STATIC gtk_plot_area.cpp gtk_plot_area.hpp gtk_input.hpp)
|
||||
add_library(plot::gtk4 ALIAS plot_gtk4)
|
||||
# The installed tree names it plot::gtk4, like the build tree (see plot_core's).
|
||||
set_target_properties(plot_gtk4 PROPERTIES EXPORT_NAME gtk4)
|
||||
|
||||
# The public include root is `adapters/`, so the headers are reached as
|
||||
# <gtk4/gtk_plot_area.hpp> and <gtk4/gtk_input.hpp> -- the toolkit's name first,
|
||||
# like every other adapter's.
|
||||
target_include_directories(plot_gtk4 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
# like every other adapter's. The build interface is that root; the install one is
|
||||
# the prefix's `include`, where both are installed under `gtk4/`, the same
|
||||
# spelling.
|
||||
target_include_directories(plot_gtk4 PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
|
||||
$<INSTALL_INTERFACE:include>)
|
||||
# GTK is PUBLIC, unlike GLFW and ImGui: the adapter's factory hands out a
|
||||
# GtkWidget, so a consumer that embeds the area needs GTK's headers and libraries
|
||||
# to put it anywhere -- the widget *is* the toolkit's object -- and GTK's include
|
||||
# directory is not one the compiler searches by default.
|
||||
target_link_libraries(plot_gtk4 PUBLIC plot::core PkgConfig::GTK4_PC)
|
||||
plot_apply_warnings(plot_gtk4)
|
||||
|
||||
# GTK came from pkg-config, which the installed config file can re-run: the
|
||||
# snippet re-creates the exact PkgConfig::GTK4_PC target the adapter's public link
|
||||
# interface names, so a consumer that links plot::gtk4 gets GTK's own include
|
||||
# directories and libraries the same way this build did.
|
||||
plot_record_adapter_export(plot_gtk4 TRUE "GTK4 was resolved by pkg-config"
|
||||
"find_dependency(PkgConfig)\npkg_check_modules(GTK4_PC REQUIRED IMPORTED_TARGET gtk4)\n")
|
||||
if(PLOT_INSTALL)
|
||||
# gtk_input.hpp is installed with the public header: the demo and the test suite
|
||||
# reach it as <gtk4/gtk_input.hpp>, and it is a toolkit-free header a consumer
|
||||
# can use without GTK.
|
||||
install(FILES gtk_plot_area.hpp gtk_input.hpp DESTINATION include/gtk4)
|
||||
endif()
|
||||
Reference in new issue
Block a user