Files
FrameAssistant/cmake/BundleQt.cmake
T
matzmanandClaude Opus 5.5 b823ff321e Bundled builds: ship Qt WebEngine (helper process, resources)
When a bundled library is Qt WebEngine, the bundler also installs
QtWebEngineProcess (plus its libraries) to libexec/, the resources and
the en-US/de locales, and points qt.conf at them. The cross image unpacks
the arm64 QtWebEngineProcess (its package can't be co-installed with the
amd64 one). Experiment for DSH-1: the Frame's system WebEngine (6.7.0,
built against FFmpeg 6) can't be loaded.

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

79 lines
4.0 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)
# Qt WebEngine (bundled only if a dashboard needs it): its helper process, resources and
# locales. Cross builds point VRDASH_WEBENGINE_PROCESS at the target's QtWebEngineProcess
# (Debian can't install the arm64 one next to the host's; see docker/cross-arm64.Dockerfile).
set(VRDASH_WEBENGINE_PROCESS "" CACHE FILEPATH
"QtWebEngineProcess to bundle (default: the one of the Qt used for the build)")
# Locales shipped with WebEngine (the full set is about 35 MB).
set(VRDASH_WEBENGINE_LOCALES en-US de)
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()
# Used by the install script only if a bundled library is Qt WebEngine.
set(webengine_process ${VRDASH_WEBENGINE_PROCESS})
if(NOT webengine_process)
set(webengine_process ${QT6_INSTALL_PREFIX}/${QT6_INSTALL_LIBEXECS}/QtWebEngineProcess)
endif()
set(webengine_resources ${QT6_INSTALL_PREFIX}/${QT6_INSTALL_DATA}/resources)
set(webengine_locales ${QT6_INSTALL_PREFIX}/${QT6_INSTALL_TRANSLATIONS}/qtwebengine_locales)
# 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()