2019-03-18 05:52:32 +00:00
|
|
|
# Copyright 2019, Collabora, Ltd.
|
|
|
|
# SPDX-License-Identifier: BSL-1.0
|
|
|
|
|
|
|
|
######
|
|
|
|
# Create a loadable OpenXR driver.
|
|
|
|
|
|
|
|
set(RUNTIME_BARE_SUFFIX monado)
|
|
|
|
set(RUNTIME_SUFFIX _${RUNTIME_BARE_SUFFIX})
|
|
|
|
|
2021-11-11 23:41:58 +00:00
|
|
|
set(RUNTIME_TARGET
|
|
|
|
${RUNTIME_PREFIX}openxr${RUNTIME_SUFFIX}
|
|
|
|
CACHE INTERNAL "" FORCE
|
|
|
|
)
|
2019-03-18 05:52:32 +00:00
|
|
|
|
2019-08-16 14:53:39 +00:00
|
|
|
# OpenXR 1.0
|
|
|
|
set(XR_API_MAJOR "1")
|
2019-03-18 05:52:32 +00:00
|
|
|
|
2021-11-11 23:41:58 +00:00
|
|
|
add_library(${RUNTIME_TARGET} MODULE target.c libopenxr.def)
|
2019-03-18 05:52:32 +00:00
|
|
|
|
2020-04-28 18:49:11 +00:00
|
|
|
# Note: Order may matter in these lists!
|
2021-11-11 23:41:58 +00:00
|
|
|
target_link_libraries(${RUNTIME_TARGET} PUBLIC aux_vk aux_os aux_util aux_math)
|
2020-04-28 18:49:11 +00:00
|
|
|
|
2020-04-29 23:11:43 +00:00
|
|
|
if(XRT_FEATURE_SERVICE)
|
2021-11-11 23:41:58 +00:00
|
|
|
target_link_libraries(${RUNTIME_TARGET} PUBLIC st_oxr ipc_client comp_client)
|
2020-04-28 23:56:27 +00:00
|
|
|
else()
|
2021-11-11 23:41:58 +00:00
|
|
|
target_link_libraries(
|
|
|
|
${RUNTIME_TARGET}
|
|
|
|
PUBLIC
|
|
|
|
st_oxr
|
|
|
|
st_prober
|
|
|
|
target_lists
|
|
|
|
target_instance
|
|
|
|
comp_main
|
|
|
|
comp_client
|
2020-04-28 23:56:27 +00:00
|
|
|
)
|
|
|
|
endif()
|
2019-03-18 05:52:32 +00:00
|
|
|
|
2020-03-04 15:54:47 +00:00
|
|
|
if(NOT MSVC)
|
|
|
|
# Force the main "negotiate" symbol's inclusion
|
2020-03-04 15:55:16 +00:00
|
|
|
# and use a version script to ensure that's the only one we expose.
|
2021-11-11 23:41:58 +00:00
|
|
|
set_property(
|
|
|
|
TARGET ${RUNTIME_TARGET}
|
2020-03-04 15:54:47 +00:00
|
|
|
APPEND_STRING
|
2021-11-11 23:41:58 +00:00
|
|
|
PROPERTY
|
|
|
|
LINK_FLAGS
|
|
|
|
"-u xrNegotiateLoaderRuntimeInterface -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libopenxr.version"
|
|
|
|
)
|
2020-03-04 16:04:57 +00:00
|
|
|
# Re-link if the version script changes.
|
2021-11-11 23:41:58 +00:00
|
|
|
set_property(
|
|
|
|
TARGET ${RUNTIME_TARGET}
|
2020-03-04 16:04:57 +00:00
|
|
|
APPEND
|
2021-11-11 23:41:58 +00:00
|
|
|
PROPERTY LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/libopenxr.version"
|
|
|
|
)
|
2020-03-04 15:54:47 +00:00
|
|
|
endif()
|
|
|
|
|
2019-06-18 20:05:58 +00:00
|
|
|
###
|
|
|
|
# Generate runtime manifest with absolute path to runtime intended for development without installing
|
2022-04-21 21:39:10 +00:00
|
|
|
|
|
|
|
# 3.9+ have a global property with the truth
|
|
|
|
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
2021-03-26 20:45:53 +00:00
|
|
|
|
|
|
|
if(IS_MULTI_CONFIG)
|
|
|
|
set(DEV_MANIFEST_OUTPUT "${CMAKE_BINARY_DIR}/$<CONFIG>/${RUNTIME_TARGET}-dev.json")
|
|
|
|
else()
|
|
|
|
set(DEV_MANIFEST_OUTPUT "${CMAKE_BINARY_DIR}/${RUNTIME_TARGET}-dev.json")
|
|
|
|
endif()
|
|
|
|
|
2022-04-21 21:39:10 +00:00
|
|
|
include(GenerateOpenXRRuntimeManifest)
|
|
|
|
generate_openxr_runtime_manifest_buildtree(
|
|
|
|
RUNTIME_TARGET ${RUNTIME_TARGET} #
|
|
|
|
OUT_FILE ${DEV_MANIFEST_OUTPUT}
|
2021-11-11 23:41:58 +00:00
|
|
|
)
|
2019-06-18 20:05:58 +00:00
|
|
|
|
2019-06-18 20:05:20 +00:00
|
|
|
###
|
|
|
|
# Prepare the installable manifest: will be generated completely at install time,
|
|
|
|
# by a script we generate now.
|
2022-04-21 21:39:10 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
# Windows: install manifest to top level
|
|
|
|
set(_extra_args)
|
|
|
|
if(XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH)
|
|
|
|
set(_extra_args ABSOLUTE_RUNTIME_PATH)
|
|
|
|
elseif(XRT_OPENXR_INSTALL_MANIFEST_RELATIVE_RUNTIME_PATH)
|
|
|
|
set(_extra_args RUNTIME_DIR_RELATIVE_TO_MANIFEST ${CMAKE_INSTALL_BINDIR})
|
|
|
|
endif()
|
|
|
|
generate_openxr_runtime_manifest_at_install(
|
|
|
|
${_extra_args}
|
|
|
|
RUNTIME_TARGET ${RUNTIME_TARGET}
|
|
|
|
DESTINATION .
|
|
|
|
RELATIVE_RUNTIME_DIR ${CMAKE_INSTALL_BINDIR}
|
|
|
|
)
|
|
|
|
set(RUNTIME_RELATIVE_DIR ${CMAKE_INSTALL_BINDIR})
|
|
|
|
elseif(NOT ANDROID)
|
|
|
|
# Linux, BSD, etc.
|
2019-06-18 20:05:20 +00:00
|
|
|
set(MANIFEST_RELATIVE_DIR share/openxr/${XR_API_MAJOR}/)
|
2020-04-29 23:11:43 +00:00
|
|
|
if(XRT_OPENXR_INSTALL_ACTIVE_RUNTIME)
|
2021-11-11 23:41:58 +00:00
|
|
|
configure_file(
|
|
|
|
active_runtime.cmake ${CMAKE_CURRENT_BINARY_DIR}/active_runtime.cmake @ONLY
|
|
|
|
)
|
2019-06-14 20:57:34 +00:00
|
|
|
install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/active_runtime.cmake)
|
|
|
|
endif()
|
2022-04-21 21:39:10 +00:00
|
|
|
|
|
|
|
set(_extra_args)
|
|
|
|
if(XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH)
|
|
|
|
set(_extra_args ABSOLUTE_RUNTIME_PATH)
|
|
|
|
elseif(XRT_OPENXR_INSTALL_MANIFEST_RELATIVE_RUNTIME_PATH)
|
|
|
|
set(_extra_args RUNTIME_DIR_RELATIVE_TO_MANIFEST ../../../${CMAKE_INSTALL_LIBDIR})
|
2022-04-20 21:04:26 +00:00
|
|
|
endif()
|
2022-04-21 21:39:10 +00:00
|
|
|
generate_openxr_runtime_manifest_at_install(
|
|
|
|
${_extra_args}
|
|
|
|
RUNTIME_TARGET ${RUNTIME_TARGET}
|
|
|
|
DESTINATION share/openxr/${XR_API_MAJOR}
|
|
|
|
RELATIVE_RUNTIME_DIR ${CMAKE_INSTALL_LIBDIR}
|
2022-04-20 21:04:26 +00:00
|
|
|
)
|
2022-04-21 21:39:10 +00:00
|
|
|
set(RUNTIME_RELATIVE_DIR ${CMAKE_INSTALL_LIBDIR})
|
2019-06-18 20:05:20 +00:00
|
|
|
endif()
|
|
|
|
|
2022-04-21 21:29:17 +00:00
|
|
|
# Install the runtime itself
|
|
|
|
install(
|
|
|
|
TARGETS ${RUNTIME_TARGET} #
|
|
|
|
LIBRARY DESTINATION ${RUNTIME_RELATIVE_DIR} #
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} #
|
|
|
|
RUNTIME DESTINATION ${RUNTIME_RELATIVE_DIR}
|
|
|
|
)
|
2021-11-11 23:41:58 +00:00
|
|
|
###
|
|
|
|
# Inelegant but effective SDL2-based debug GUI
|
|
|
|
add_library(oxr_sdl2 STATIC oxr_sdl2_hack.c)
|
|
|
|
target_link_libraries(oxr_sdl2 PRIVATE aux_util)
|
|
|
|
if(XRT_HAVE_OPENGL)
|
|
|
|
target_link_libraries(oxr_sdl2 PUBLIC aux_ogl)
|
|
|
|
endif()
|
|
|
|
if(XRT_HAVE_SDL2)
|
|
|
|
target_link_libraries(oxr_sdl2 PRIVATE st_gui xrt-external-imgui-sdl2 ${SDL2_LIBRARIES})
|
|
|
|
|
|
|
|
if(XRT_BUILD_DRIVER_QWERTY)
|
|
|
|
target_link_libraries(oxr_sdl2 PRIVATE drv_qwerty drv_qwerty_includes)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
target_link_libraries(${RUNTIME_TARGET} PRIVATE oxr_sdl2)
|