feat(imgui): embeddable plot widget and demo

This commit is contained in:
Martino Ferrari committed 2026-09-28 00:38:31 +02:00
1 parent fb2c2f5e4d
commit 15931a2405
9 files changed
+1072 -38

No files matched your search

+50
View File
@@ -31,3 +31,53 @@ function(plot_apply_warnings target)
-Wshadow)
endif()
endfunction()
# Resolves GLFW once for every target that needs it -- the GLFW host adapter and
# the Dear ImGui backend both do. Discovery follows the design spec's order:
# find_package first, pkg-config next, FetchContent only when neither can supply
# GLFW (the last resort, because it needs the network). The result is cached in
# PLOT_GLFW_DEP, so a build with several adapters enabled discovers -- and at
# worst fetches -- exactly one copy. Sets <out_var> to the target to link.
function(plot_find_glfw out_var)
if(NOT DEFINED PLOT_GLFW_DEP)
set(plot_glfw_dep "")
find_package(glfw3 3.3 QUIET)
if(TARGET glfw)
set(plot_glfw_dep glfw)
elseif(TARGET glfw3::glfw3)
set(plot_glfw_dep glfw3::glfw3)
endif()
if(NOT plot_glfw_dep)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(GLFW_PC QUIET IMPORTED_TARGET glfw3)
if(TARGET PkgConfig::GLFW_PC)
set(plot_glfw_dep PkgConfig::GLFW_PC)
endif()
endif()
endif()
if(NOT plot_glfw_dep)
message(STATUS "plot: glfw3 not found via find_package or pkg-config; fetching it")
include(FetchContent)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_Declare(glfw
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG 3.4
GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(glfw)
set(plot_glfw_dep glfw)
endif()
set(PLOT_GLFW_DEP "${plot_glfw_dep}" CACHE INTERNAL
"GLFW target the plot adapters link against")
message(STATUS "plot: GLFW adapter dependency: ${plot_glfw_dep}")
endif()
set(${out_var} "${PLOT_GLFW_DEP}" PARENT_SCOPE)
endfunction()