Demo: Fix the lib crash issue on Android and rename Xr Demo

-standardized xr_physicsbase_teleportation top-level CMake
-Standardized Android manifest file, this fixed a crash due to a lib
name not being up to date, and then not being found.

Pick-to: 6.10 6.10.0
Change-Id: Ib36d3790e5061b14a27f7fef7c24f5e2040ddb67
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
This commit is contained in:
Nicholas Bennett 2025-09-11 10:54:09 +03:00
parent 480007766c
commit 139629b616
2 changed files with 35 additions and 19 deletions

View File

@ -2,23 +2,16 @@
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.14)
project(XRPhysicsBaseTeleportationDemo LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
if(NOT DEFINED INSTALL_EXAMPLESDIR)
set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/vr/${PROJECT_NAME}")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick Quick3D Quick3DPhysics Quick3DXr Multimedia)
qt6_policy(SET QTP0002 NEW)
qt_standard_project_setup(REQUIRES 6.8)
qt_add_executable(${PROJECT_NAME}
main.cpp
android/AndroidManifest.xml
)
set_target_properties(${PROJECT_NAME} PROPERTIES
@ -33,7 +26,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
Qt::Quick3D
Qt::Quick3DPhysics
Qt::Quick3DXr
Qt6::Multimedia
Qt::Multimedia
)
set(qml_singletons
@ -47,6 +40,16 @@ set(qml_singletons
set_source_files_properties(${qml_singletons}
PROPERTIES QT_QML_SINGLETON_TYPE TRUE)
if(ANDROID)
set_target_properties(${PROJECT_NAME} PROPERTIES
QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android"
QT_ANDROID_PACKAGE_NAME "io.qt.demo.${PROJECT_NAME}"
QT_ANDROID_TARGET_SDK_VERSION 34
QT_ANDROID_VERSION_CODE 10
QT_ANDROID_VERSION_NAME "1.0"
)
endif()
# Resources:
qt_add_qml_module(${PROJECT_NAME}
URI EXAMPLE
@ -171,11 +174,18 @@ qt_add_qml_module(${PROJECT_NAME}
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}
)
if(ANDROID)
set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android)
endif()
qt_generate_deploy_qml_app_script(
TARGET ${PROJECT_NAME}
OUTPUT_SCRIPT deploy_script
MACOS_BUNDLE_POST_BUILD
NO_UNSUPPORTED_PLATFORM_ERROR
DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
install(SCRIPT ${deploy_script})

View File

@ -3,8 +3,12 @@
https://developer.oculus.com/documentation/native/android/mobile-native-manifest/
https://developer.oculus.com/resources/publish-mobile-manifest/
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.qtproject.example.xr_physicsbase_teleportation"
android:installLocation="auto" android:versionCode="1" android:versionName="1.0">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
android:versionCode="-- %%INSERT_VERSION_CODE%% --"
android:versionName="-- %%INSERT_VERSION_NAME%% --">
<!-- %%INSERT_PERMISSIONS -->
<!-- %%INSERT_FEATURES -->
<uses-permission android:name="org.khronos.openxr.permission.OPENXR"/>
<uses-permission android:name="org.khronos.openxr.permission.OPENXR_SYSTEM"/>
<uses-feature android:name="android.hardware.vr.headtracking" android:required="true" android:version="1" />
@ -27,7 +31,9 @@
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="org.khronos.openxr.intent.category.IMMERSIVE_HMD"/>
</intent-filter>
<meta-data android:name="android.app.lib_name" android:value="xr_physicsbase_teleportation"/>
<meta-data
android:name="android.app.lib_name"
android:value="-- %%INSERT_APP_LIB_NAME%% --" />
</activity>
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.qtprovider"
android:exported="false" android:grantUriPermissions="true">