Files
FrameAssistant/cmake/BundleQt.cmake
T
matzmanandClaude Opus 5.5 4a5b09053e Initial FrameAssistant baseline from the vrdashboard template
Template stripped to the overlay platform (examples, demo UI and Frame
test package removed), renamed to FrameAssistant, and working rules for
the project recorded in CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 00:06:58 +02:00

63 lines
3.1 KiB
CMake

# vrdash_bundle_qt()
#
# Call once, after all dashboards are defined (vrdash_add_dashboard() registers them).
# Adds an install step that makes the install prefix self-contained for all of them
# together: the Qt libraries
# (and their non-system dependencies), required Qt plugins and the QML modules the UI
# imports are copied next to the executable, RPATHs are made relative and a qt.conf is
# written. Works for native AND cross builds (Qt's own qt_generate_deploy_*_app_script
# refuses cross-compiled Linux targets, and with a /usr Qt it would bundle glibc too).
#
# Libraries matched by VRDASH_BUNDLE_EXCLUDE are expected on the target system
# (SteamOS): libc, the C++ runtime and everything tied to the GPU driver / display
# server. Bundling those would break GPU access, so they always come from the host.
# Regexes are matched against DT_NEEDED names.
set(VRDASH_BUNDLE_EXCLUDE
"^ld-linux" "^libc\\.so" "^libm\\.so" "^libdl\\.so" "^libpthread\\.so" "^librt\\.so"
"^libresolv\\.so" "^libutil\\.so" "^libstdc\\+\\+\\.so" "^libgcc_s\\.so"
"^libGL" "^libEGL" "^libOpenGL" "^libGLX" "^libGLdispatch" "^libgbm" "^libdrm"
"^libvulkan" "^libwayland-" "^libX" "^libxcb" "^libxkbcommon" "^libxshmfence"
"^libfontconfig" "^libfreetype" "^libexpat" "^libz\\.so"
"^libdbus-1" "^libsystemd" "^libudev" "^libcap\\.so" "^libgcrypt" "^libgpg-error"
"^liblzma" "^liblz4" "^libzstd" "^libffi"
"^libopenvr_api")
# SteamVR's process environment decides the platform (Wayland under gamescope/Plasma,
# XWayland via DISPLAY, or offscreen); embedded platforms (eglfs, vnc, …) are left out.
set(VRDASH_BUNDLE_PLUGINS
platforms/libqwayland-*.so platforms/libqxcb.so platforms/libqoffscreen.so
wayland-shell-integration/*.so wayland-graphics-integration-client/*.so
wayland-decoration-client/*.so xcbglintegrations/*.so)
function(vrdash_bundle_qt)
get_property(targets GLOBAL PROPERTY VRDASH_DASHBOARD_TARGETS)
get_property(qml_dirs GLOBAL PROPERTY VRDASH_DASHBOARD_QML_DIRS)
set(executables "")
foreach(target IN LISTS targets)
list(APPEND executables "$<TARGET_FILE_NAME:${target}>")
endforeach()
find_program(VRDASH_PATCHELF patchelf REQUIRED)
if(CMAKE_CROSSCOMPILING)
# Inspect target ELF files with the target toolchain's objdump.
set(objdump ${CMAKE_OBJDUMP})
else()
find_program(objdump objdump REQUIRED)
endif()
set(qt_prefix ${QT6_INSTALL_PREFIX})
set(qt_libdir ${QT6_INSTALL_PREFIX}/${QT6_INSTALL_LIBS})
if(CMAKE_LIBRARY_ARCHITECTURE AND EXISTS ${qt_prefix}/lib/${CMAKE_LIBRARY_ARCHITECTURE})
set(qt_libdir ${qt_prefix}/lib/${CMAKE_LIBRARY_ARCHITECTURE}) # Debian multiarch
endif()
# The regexes end up inside a quoted string in the generated script: escape backslashes.
string(REPLACE "\\" "\\\\" bundle_exclude "${VRDASH_BUNDLE_EXCLUDE}")
set(script ${CMAKE_BINARY_DIR}/bundle-qt.cmake)
configure_file(${PROJECT_SOURCE_DIR}/cmake/bundle-install.cmake.in ${script}.in @ONLY)
file(GENERATE OUTPUT ${script} INPUT ${script}.in)
install(SCRIPT ${script})
endfunction()