From fc98db14397e40d9619ab52c10d3de146d2153d6 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Tue, 18 Jun 2019 15:05:20 -0500 Subject: [PATCH] oxr: Use an absolute path in the installed runtime manifest. --- src/xrt/targets/openxr/CMakeLists.txt | 23 +++++++++++++++----- src/xrt/targets/openxr/make_manifest.cmake | 23 ++++++++++++++++++++ src/xrt/targets/openxr/openxr_monado.in.json | 6 +++++ 3 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 src/xrt/targets/openxr/make_manifest.cmake create mode 100644 src/xrt/targets/openxr/openxr_monado.in.json diff --git a/src/xrt/targets/openxr/CMakeLists.txt b/src/xrt/targets/openxr/CMakeLists.txt index 57ebcdb46..31ff1cef6 100644 --- a/src/xrt/targets/openxr/CMakeLists.txt +++ b/src/xrt/targets/openxr/CMakeLists.txt @@ -74,11 +74,6 @@ if(DRIVER_LIBRARIES) target_link_libraries(${RUNTIME_TARGET} PRIVATE ${DRIVER_LIBRARIES}) endif() -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - install(FILES "${CMAKE_BINARY_DIR}/${RUNTIME_TARGET}.json" DESTINATION "share/openxr/${XR_API_MAJOR}/") -elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") - # TODO: install target on windows -endif() include(GNUInstallDirs) # Install the runtime itself @@ -86,3 +81,21 @@ install(TARGETS ${RUNTIME_TARGET} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +set(MANIFEST_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/openxr_monado.in.json) +### +# Prepare the installable manifest: will be generated completely at install time, +# by a script we generate now. +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(MANIFEST_RELATIVE_DIR share/openxr/${XR_API_MAJOR}/) + +elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") + # TODO: install target on windows just needs to know where to install manifest + set(MANIFEST_RELATIVE_DIR) +endif() + +# If we know where to install the manifest, we can set it up to be installed. +if(MANIFEST_RELATIVE_DIR) + set(RUNTIME_RELATIVE_PATH ${CMAKE_INSTALL_LIBDIR}/${CMAKE_SHARED_MODULE_PREFIX}${RUNTIME_TARGET}${CMAKE_SHARED_MODULE_SUFFIX}) + configure_file(make_manifest.cmake ${CMAKE_CURRENT_BINARY_DIR}/make_manifest.cmake @ONLY) + install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/make_manifest.cmake) +endif() diff --git a/src/xrt/targets/openxr/make_manifest.cmake b/src/xrt/targets/openxr/make_manifest.cmake new file mode 100644 index 000000000..31b42bd9c --- /dev/null +++ b/src/xrt/targets/openxr/make_manifest.cmake @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: BSL-1.0 + +# Get input from main CMake script +set(MANIFEST_INPUT @MANIFEST_INPUT@) +set(MANIFEST_RELATIVE_DIR @MANIFEST_RELATIVE_DIR@) +set(RUNTIME_RELATIVE_PATH @RUNTIME_RELATIVE_PATH@) + +# Remove trailing slash +string(REGEX REPLACE "/$" "" MANIFEST_RELATIVE_DIR "${MANIFEST_RELATIVE_DIR}") + +set(RUNTIME_PATH ${CMAKE_INSTALL_PREFIX}/${RUNTIME_RELATIVE_PATH}) + +if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT) + + # Create manifest + configure_file(${MANIFEST_INPUT} ${CMAKE_CURRENT_LIST_DIR}/@RUNTIME_TARGET@.json) + + # Install it + file(INSTALL + DESTINATION "${CMAKE_INSTALL_PREFIX}/${MANIFEST_RELATIVE_DIR}" + TYPE FILE + FILES "${CMAKE_CURRENT_LIST_DIR}/@RUNTIME_TARGET@.json") +endif() diff --git a/src/xrt/targets/openxr/openxr_monado.in.json b/src/xrt/targets/openxr/openxr_monado.in.json new file mode 100644 index 000000000..c1a469e09 --- /dev/null +++ b/src/xrt/targets/openxr/openxr_monado.in.json @@ -0,0 +1,6 @@ +{ + "file_format_version": "1.0.0", + "runtime": { + "library_path": "${RUNTIME_PATH}" + } +}