From c1a0fe18341f4bddf565ce22f9fe2125f6097687 Mon Sep 17 00:00:00 2001 From: Michael Tao Date: Mon, 24 Aug 2026 00:52:14 -0400 Subject: [PATCH] build: isolate visualization frontends --- .github/workflows/system-packages.yml | 33 ++++++++++++++ meson_options.txt | 6 +-- visualization/examples/meson.build | 19 ++++++-- visualization/meson.build | 29 +++++++++++- visualization/tools/meson.build | 64 +++++++++++++++------------ 5 files changed, 113 insertions(+), 38 deletions(-) diff --git a/.github/workflows/system-packages.yml b/.github/workflows/system-packages.yml index 0c21417..86b806c 100644 --- a/.github/workflows/system-packages.yml +++ b/.github/workflows/system-packages.yml @@ -139,6 +139,39 @@ jobs: - name: Build run: meson compile -C build/ + - name: Verify Qt-only frontend + if: matrix.build_type == 'debug' + env: + CC: ccache ${{ matrix.platform.cc }} + CXX: ccache ${{ matrix.platform.cxx }} + run: | + meson setup build-qt-only/ \ + --buildtype=debug \ + --wrap-mode=forcefallback \ + -Dtesting=false -Dexamples=false \ + -Dqt=true -Dglfw=false -Dimgui=false + ninja -C build-qt-only/ \ + visualization/libbalsaVisualization.so.p/src_qt_vulkan_film.cpp.o \ + visualization/libbalsaVisualization.so.p/src_qt_vulkan_window.cpp.o \ + visualization/tools/mesh_viewer_qt.p/mesh_viewer_qt.cpp.o + + - name: Verify GLFW ImGui frontend + if: matrix.build_type == 'debug' + env: + CC: ccache ${{ matrix.platform.cc }} + CXX: ccache ${{ matrix.platform.cxx }} + run: | + meson setup build-glfw-imgui/ \ + --buildtype=debug \ + --wrap-mode=forcefallback \ + -Dtesting=false -Dexamples=false \ + -Dqt=false -Dglfw=true -Dimgui=true + ninja -C build-glfw-imgui/ \ + visualization/libbalsaVisualization.so.p/src_glfw_vulkan_film.cpp.o \ + visualization/libbalsaVisualization.so.p/src_glfw_vulkan_window.cpp.o \ + visualization/libbalsaVisualization.so.p/src_vulkan_imgui_integration.cpp.o \ + visualization/tools/mesh_viewer_glfw.p/mesh_viewer_glfw.cpp.o + - name: ccache stats run: ccache -s diff --git a/meson_options.txt b/meson_options.txt index 2cc7db2..bea2486 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -6,10 +6,10 @@ option('openvdb', type : 'boolean', value : false, description : 'Build openvdb option('json', type : 'boolean', value : true, description : 'Use json') option('protobuf', type : 'boolean', value : false, description : 'Use protobuf') option('partio', type : 'boolean', value : false, description : 'Use partio') -option('imgui', type : 'boolean', value : true, description : 'Use imgui') +option('imgui', type : 'boolean', value : true, description : 'Build the ImGui UI frontend (currently requires GLFW)') option('alembic', type : 'boolean', value : false, description : 'Use alembic') option('perfetto', type : 'boolean', value : false, description : 'Use perfetto') option('visualization', type : 'boolean', value : true, description : 'Build visualization library') -option('glfw', type : 'boolean', value : true, description : 'Use glfw') -option('qt', type : 'boolean', value : true, description : 'Use qt') +option('glfw', type : 'boolean', value : true, description : 'Build the GLFW window backend') +option('qt', type : 'boolean', value : true, description : 'Build the Qt window and widget frontend') diff --git a/visualization/examples/meson.build b/visualization/examples/meson.build index ca8d294..a767146 100644 --- a/visualization/examples/meson.build +++ b/visualization/examples/meson.build @@ -1,5 +1,16 @@ -test_example_scene_dep = static_library('vulkan_scene', 'vulkan_scene.cpp', dependencies: [visualization_dep]) -executable('vulkan_window', 'vulkan_window.cpp', 'vulkan_scene.cpp', dependencies: [visualization_dep]) -#executable('test_vulkan_window', 'test_vulkan_window.cpp', 'example_vulkan_scene.cpp', dependencies: [visualization_dep]) -executable('vulkan_window_glfw', 'vulkan_window_glfw.cpp', dependencies: [visualization_dep], link_with: [test_example_scene_dep]) +# The existing example scene includes an ImGui overlay, so only build it for +# the GLFW + ImGui frontend. Qt-only examples should not acquire ImGui. +if get_option('glfw') and get_option('imgui') + test_example_scene_dep = static_library( + 'vulkan_scene', + 'vulkan_scene.cpp', + dependencies: [visualization_dep], + ) + executable( + 'vulkan_window_glfw', + 'vulkan_window_glfw.cpp', + dependencies: [visualization_dep], + link_with: [test_example_scene_dep], + ) +endif diff --git a/visualization/meson.build b/visualization/meson.build index a94b85c..317ec00 100644 --- a/visualization/meson.build +++ b/visualization/meson.build @@ -6,6 +6,10 @@ vulkan_dep = dependency('vulkan', required: false) shaderc_dep = dependency('shaderc') +if get_option('imgui') and not get_option('glfw') + error('The ImGui frontend currently requires GLFW; enable -Dglfw=true or disable -Dimgui') +endif + # Shader source files are part of the dependency contract, so a binary system # package cannot satisfy it. Always use the pinned source subproject. colormap_proj = subproject('colormap_shaders') @@ -42,7 +46,28 @@ endif imgui_backend_sources = [] imgui_backend_inc = [] if get_option('imgui') - imgui_dep = dependency('imgui') + imgui_dep = dependency( + 'imgui', + default_options: [ + 'dx9=disabled', + 'dx10=disabled', + 'dx11=disabled', + 'dx12=disabled', + 'metal=disabled', + 'opengl=disabled', + 'sdl2_renderer=disabled', + 'sdl3_renderer=disabled', + 'sdl3_gpu=disabled', + 'vulkan=enabled', + 'webgpu=disabled', + 'glfw=enabled', + 'sdl2=disabled', + 'sdl3=disabled', + 'osx=disabled', + 'win=disabled', + 'allegro5=disabled', + ], + ) if imgui_dep.type_name() != 'internal' imgui_prefix = imgui_dep.get_variable(pkgconfig: 'prefix') imgui_bd = imgui_prefix / 'res' / 'bindings' @@ -148,7 +173,7 @@ meson.override_dependency('balsaVisualization', visualization_dep) if get_option('testing') subdir('tests') endif -if get_option('examples') +if get_option('examples') and get_option('glfw') and get_option('imgui') subdir('examples') endif subdir('tools') diff --git a/visualization/tools/meson.build b/visualization/tools/meson.build index 959dc91..da7f10d 100644 --- a/visualization/tools/meson.build +++ b/visualization/tools/meson.build @@ -1,35 +1,41 @@ -cli11_dep = dependency('CLI11', required: false, allow_fallback: true) - -# ── mesh_viewer_glfw ───────────────────────────────────────────────── -mesh_viewer_glfw_deps = [visualization_dep] -mesh_viewer_glfw_args = [] -if cli11_dep.found() - mesh_viewer_glfw_deps += cli11_dep - mesh_viewer_glfw_args += '-DBALSA_HAS_CLI11=1' +if get_option('qt') or (get_option('glfw') and get_option('imgui')) + cli11_dep = dependency('CLI11', required: false, allow_fallback: true) endif -executable('mesh_viewer_glfw', 'mesh_viewer_glfw.cpp', - dependencies: mesh_viewer_glfw_deps, - cpp_args: mesh_viewer_glfw_args) -# ── mesh_viewer_qt ─────────────────────────────────────────────────── -mesh_viewer_qt_deps = [visualization_dep] -mesh_viewer_qt_args = [] -if cli11_dep.found() - mesh_viewer_qt_deps += cli11_dep - mesh_viewer_qt_args += '-DBALSA_HAS_CLI11=1' +if get_option('glfw') and get_option('imgui') + # ── mesh_viewer_glfw ─────────────────────────────────────────────── + mesh_viewer_glfw_deps = [visualization_dep] + mesh_viewer_glfw_args = [] + if cli11_dep.found() + mesh_viewer_glfw_deps += cli11_dep + mesh_viewer_glfw_args += '-DBALSA_HAS_CLI11=1' + endif + executable('mesh_viewer_glfw', 'mesh_viewer_glfw.cpp', + dependencies: mesh_viewer_glfw_deps, + cpp_args: mesh_viewer_glfw_args) + + # ── image_viewer_glfw ────────────────────────────────────────────── + image_viewer_glfw_deps = [visualization_dep] + image_viewer_glfw_args = [] + if cli11_dep.found() + image_viewer_glfw_deps += cli11_dep + image_viewer_glfw_args += '-DBALSA_HAS_CLI11=1' + endif + executable('image_viewer_glfw', 'image_viewer_glfw.cpp', + dependencies: image_viewer_glfw_deps, + cpp_args: image_viewer_glfw_args) endif -executable('mesh_viewer_qt', 'mesh_viewer_qt.cpp', - dependencies: mesh_viewer_qt_deps, - cpp_args: mesh_viewer_qt_args) -# ── image_viewer_glfw ──────────────────────────────────────────────── -image_viewer_glfw_deps = [visualization_dep] -image_viewer_glfw_args = [] -if cli11_dep.found() - image_viewer_glfw_deps += cli11_dep - image_viewer_glfw_args += '-DBALSA_HAS_CLI11=1' +if get_option('qt') + # ── mesh_viewer_qt ───────────────────────────────────────────────── + mesh_viewer_qt_deps = [visualization_dep] + mesh_viewer_qt_args = [] + if cli11_dep.found() + mesh_viewer_qt_deps += cli11_dep + mesh_viewer_qt_args += '-DBALSA_HAS_CLI11=1' + endif + executable('mesh_viewer_qt', 'mesh_viewer_qt.cpp', + dependencies: mesh_viewer_qt_deps, + cpp_args: mesh_viewer_qt_args) endif -executable('image_viewer_glfw', 'image_viewer_glfw.cpp', - dependencies: image_viewer_glfw_deps, - cpp_args: image_viewer_glfw_args)