# The GTK4 adapter: a GtkGLArea whose own framebuffer the plot is rendered into # and driven from GTK's gestures and event controllers. GTK is a C library whose # GL widget cannot be subclassed from C++ (`G_DEFINE_TYPE` declares the type's # instance and class structs), so the adapter is a factory that builds an instance # and wraps it -- the shape the header documents. # # Unlike GLFW and ImGui -- and like Qt -- this is not a fetched dependency: GTK4 # is a system SDK, and a project that enables this target is asking for the # installed one. Discovery is pkg-config, and a missing GTK4 fails configuration # with the fix in the message. find_package(PkgConfig QUIET) if(PkgConfig_FOUND) pkg_check_modules(GTK4_PC QUIET IMPORTED_TARGET gtk4) endif() if(NOT TARGET PkgConfig::GTK4_PC) message(FATAL_ERROR "plot: PLOT_BUILD_GTK4 is ON but GTK4 was not found (pkg-config gtk4). Install the " "GTK4 development package -- on Arch, gtk4 -- or configure with -DPLOT_BUILD_GTK4=OFF, " "or point PKG_CONFIG_PATH at the GTK4 .pc file.") 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 public include root is `adapters/`, so the headers are reached as # and -- the toolkit's name first, # like every other adapter's. target_include_directories(plot_gtk4 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..") # 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)