Files
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

73 lines
3.3 KiB
CMake

# vrdash_add_dashboard(<target>
# OUTPUT_NAME <executable file name>
# QML_URI <QML module URI>
# SOURCES <main.cpp and other plain C++>
# [QML_SOURCES <C++ with QML_ELEMENT types>]
# QML_FILES <.qml files>)
#
# A dashboard executable on top of vrdashboard_core (DashboardApp), with everything
# all dashboards share: its QML module, bytecode-only QML for system-Qt builds,
# libopenvr_api.so next to it, installation, registration for vrdash_bundle_qt().
# SteamVR identifies processes by executable name: never use one of its own (an
# executable called "vrdashboard" made SteamVR treat us as its dashboard).
set(VRDASH_RESERVED_EXECUTABLE_NAMES
vrdashboard vrserver vrcompositor vrmonitor vrstartup vrwebhelper vrservice
vrpathreg vrcmd)
function(vrdash_add_dashboard target)
cmake_parse_arguments(PARSE_ARGV 1 arg "" "OUTPUT_NAME;QML_URI"
"SOURCES;QML_SOURCES;QML_FILES")
if(arg_OUTPUT_NAME IN_LIST VRDASH_RESERVED_EXECUTABLE_NAMES)
message(FATAL_ERROR "Executable name '${arg_OUTPUT_NAME}' collides with a SteamVR process")
endif()
# The QML module's URI becomes DashboardApplication's default module, so it
# is written down only here (QML_URI).
set(uri_source ${CMAKE_CURRENT_BINARY_DIR}/${target}_qml_module.cpp)
file(GENERATE OUTPUT ${uri_source} CONTENT
"// Generated by vrdash_add_dashboard() (cmake/Dashboard.cmake).
#include \"app/DashboardApplication.h\"
namespace {
[[maybe_unused]] const bool registered =
(DashboardApplication::setDefaultQmlModule(\"${arg_QML_URI}\"), true);
} // namespace
")
qt_add_executable(${target} ${arg_SOURCES} ${uri_source})
set_target_properties(${target} PROPERTIES OUTPUT_NAME ${arg_OUTPUT_NAME})
target_link_libraries(${target} PRIVATE vrdashboard_core)
target_compile_options(${target} PRIVATE -Wall -Wextra)
if(VRDASH_QML_BYTECODE_ONLY)
# Must be set before qt_add_qml_module() reads it.
set_target_properties(${target} PROPERTIES QT_QMLCACHEGEN_ARGUMENTS --only-bytecode)
endif()
qt_add_qml_module(${target}
URI ${arg_QML_URI}
VERSION 1.0
SOURCES ${arg_QML_SOURCES}
QML_FILES ${arg_QML_FILES})
get_target_property(_qt_core_type Qt6::Core TYPE)
if(_qt_core_type STREQUAL "SHARED_LIBRARY")
# The import scan links QML plugins statically and is only meant for static Qt;
# with Debian's shared Qt it misfires (warnings). Shared Qt loads them at runtime.
set_target_properties(${target} PROPERTIES QT_QML_MODULE_NO_IMPORT_SCAN ON)
endif()
# libopenvr_api.so is not a system library: <prefix>/lib, found via RPATH.
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${OPENVR_LIBRARY}
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/
VERBATIM)
install(TARGETS ${target} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# For vrdash_bundle_qt(), which bundles for all dashboards at once.
set_property(GLOBAL APPEND PROPERTY VRDASH_DASHBOARD_TARGETS ${target})
set_property(GLOBAL APPEND PROPERTY VRDASH_DASHBOARD_QML_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/qml)
endfunction()