Skip to content

Commit 3bfe860

Browse files
author
Nick Klingensmith
committed
Details for custom OpenXR Loaders.
Signed-off-by: Nick Klingensmith <quic_nklingen@quicinc.com>
1 parent c0aed7c commit 3bfe860

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ set(ANDROID_PACKAGE_NAME "com.example.${PROJECT_NAME}")
5151
set(ANDROID_MIN_SDK_VERSION 29)
5252
set(ANDROID_TARGET_SDK_VERSION 32)
5353

54+
# If you need to use a custom OpenXR Loader, uncomment this line and change the
55+
# path to the loader you want!
56+
#set(OPENXR_CUSTOM_LOADER "${CMAKE_SOURCE_DIR}/loader/snapdragon/libopenxr_loader.so")
57+
5458
#######################################
5559
## Primary Target ##
5660
#######################################
@@ -87,6 +91,9 @@ include(FetchContent)
8791
set(SK_BUILD_TESTS OFF CACHE INTERNAL "")
8892
set(SK_BUILD_SHARED_LIBS ON CACHE INTERNAL "") # Shared libraries allows for faster builds!
8993
set(SK_PHYSICS OFF CACHE INTERNAL "") # SK Physics is deprecated, simplifies build.
94+
if (ANDROID AND DEFINED OPENXR_CUSTOM_LOADER)
95+
set(SK_DYNAMIC_OPENXR ON CACHE INTERNAL "")
96+
endif()
9097
FetchContent_Declare(
9198
StereoKitC
9299
GIT_REPOSITORY https://github.com/StereoKit/StereoKit.git
@@ -102,6 +109,14 @@ target_link_libraries( ${PROJECT_NAME}
102109
PRIVATE StereoKitC
103110
)
104111

112+
# If a custom OpenXR Loader binary has been specified, we can add it to the
113+
# project as a shared library!
114+
if (ANDROID AND DEFINED OPENXR_CUSTOM_LOADER)
115+
add_library (custom_openxr_loader SHARED IMPORTED)
116+
set_target_properties(custom_openxr_loader PROPERTIES IMPORTED_LOCATION ${OPENXR_CUSTOM_LOADER})
117+
target_link_libraries(${PROJECT_NAME} PRIVATE custom_openxr_loader)
118+
endif()
119+
105120
# This needs to be called after all libraries have been linked to
106121
# ${PROJECT_NAME}, or their shared binaries will be missed when building the
107122
# APK!

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,8 @@ cmake -B build-android ^
112112
cmake --build build-android -j8 --target run
113113
# Or just build an APK
114114
cmake --build build-android -j8 --target apk
115-
```
115+
```
116+
117+
## Custom OpenXR Loader
118+
119+
If you need to use a custom OpenXR Loader for a non-conformant runtime such as Snapdragon Spaces, you can specify it with the `OPENXR_CUSTOM_LOADER` variable! See the CMakeLists.txt file for a commented out example. Note that you may need to do a _full_ clean and rebuild if you're switching between the standard and a custom loader. It may be better to have a different build folder per-loader.

0 commit comments

Comments
 (0)