diff --git a/src/xrt/targets/openxr/CMakeLists.txt b/src/xrt/targets/openxr/CMakeLists.txt index 3fede2788..919ab06bc 100644 --- a/src/xrt/targets/openxr/CMakeLists.txt +++ b/src/xrt/targets/openxr/CMakeLists.txt @@ -55,23 +55,9 @@ endif() ### # Generate runtime manifest with absolute path to runtime intended for development without installing -set(MANIFEST_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/openxr_monado.in.json) -set(runtime_path $>) -# Need this step because file(GENERATE) only evaluates generator expressions, and not what configure_file does. -configure_file(${MANIFEST_INPUT} ${CMAKE_CURRENT_BINARY_DIR}/intermediate_manifest.json) - -if(CMAKE_VERSION VERSION_LESS 3.9) - # best guess - if(CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - set(IS_MULTI_CONFIG FALSE) - else() - set(IS_MULTI_CONFIG TRUE) - endif() -else() - # 3.9+ have a global property with the truth - get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -endif() +# 3.9+ have a global property with the truth +get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTI_CONFIG) set(DEV_MANIFEST_OUTPUT "${CMAKE_BINARY_DIR}/$/${RUNTIME_TARGET}-dev.json") @@ -79,16 +65,32 @@ else() set(DEV_MANIFEST_OUTPUT "${CMAKE_BINARY_DIR}/${RUNTIME_TARGET}-dev.json") endif() -file( - GENERATE - OUTPUT "${DEV_MANIFEST_OUTPUT}" - INPUT ${CMAKE_CURRENT_BINARY_DIR}/intermediate_manifest.json +include(GenerateOpenXRRuntimeManifest) +generate_openxr_runtime_manifest_buildtree( + RUNTIME_TARGET ${RUNTIME_TARGET} # + OUT_FILE ${DEV_MANIFEST_OUTPUT} ) ### # Prepare the installable manifest: will be generated completely at install time, # by a script we generate now. -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") +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. set(MANIFEST_RELATIVE_DIR share/openxr/${XR_API_MAJOR}/) if(XRT_OPENXR_INSTALL_ACTIVE_RUNTIME) configure_file( @@ -96,21 +98,20 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") ) install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/active_runtime.cmake) endif() + + 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}) + endif() + generate_openxr_runtime_manifest_at_install( + ${_extra_args} + RUNTIME_TARGET ${RUNTIME_TARGET} + DESTINATION share/openxr/${XR_API_MAJOR} + RELATIVE_RUNTIME_DIR ${CMAKE_INSTALL_LIBDIR} + ) set(RUNTIME_RELATIVE_DIR ${CMAKE_INSTALL_LIBDIR}) - if(XRT_OPENXR_INSTALL_MANIFEST_RELATIVE_RUNTIME_PATH - AND NOT XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH - ) - set(RUNTIME_DIR_RELATIVE_TO_MANIFEST ../../../${RUNTIME_RELATIVE_DIR}) - endif() -elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") - # Windows: install manifest to top level - set(MANIFEST_RELATIVE_DIR .) - set(RUNTIME_RELATIVE_DIR ${CMAKE_INSTALL_BINDIR}) - if(XRT_OPENXR_INSTALL_MANIFEST_RELATIVE_RUNTIME_PATH - AND NOT XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH - ) - set(RUNTIME_DIR_RELATIVE_TO_MANIFEST ./${RUNTIME_RELATIVE_DIR}) - endif() endif() # Install the runtime itself @@ -120,16 +121,6 @@ install( ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # RUNTIME DESTINATION ${RUNTIME_RELATIVE_DIR} ) - -# If we know where to install the manifest, we can set it up to be installed. -if(MANIFEST_RELATIVE_DIR) - set(RUNTIME_FILENAME - ${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() - ### # Inelegant but effective SDL2-based debug GUI add_library(oxr_sdl2 STATIC oxr_sdl2_hack.c) diff --git a/src/xrt/targets/openxr/make_manifest.cmake b/src/xrt/targets/openxr/make_manifest.cmake deleted file mode 100644 index 9042d103c..000000000 --- a/src/xrt/targets/openxr/make_manifest.cmake +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2019-2022, Collabora, Ltd. -# Copyright 2019, Benjamin Saunders -# SPDX-License-Identifier: BSL-1.0 - -# Get input from main CMake script -set(MANIFEST_INPUT @MANIFEST_INPUT@) -# Manifest install dir relative to install prefix -set(MANIFEST_RELATIVE_DIR @MANIFEST_RELATIVE_DIR@) -# Runtime install dir relative to install prefix -set(RUNTIME_RELATIVE_DIR @RUNTIME_RELATIVE_DIR@) -# Runtime so/dll filename -set(RUNTIME_FILENAME @RUNTIME_FILENAME@) -# The relative path from the manifest dir to the runtime. Optional. -set(RUNTIME_DIR_RELATIVE_TO_MANIFEST @RUNTIME_DIR_RELATIVE_TO_MANIFEST@) -# Config option -set(XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH @XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH@) - -# Remove trailing slash -string(REGEX REPLACE "/$" "" MANIFEST_RELATIVE_DIR "${MANIFEST_RELATIVE_DIR}") - -if(XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH) - # Absolute path to runtime - set(RUNTIME_PATH ${RUNTIME_RELATIVE_DIR}/${RUNTIME_FILENAME}) - if(NOT IS_ABSOLUTE ${RUNTIME_RELATIVE_DIR}) - set(RUNTIME_PATH ${CMAKE_INSTALL_PREFIX}/${RUNTIME_PATH}) - endif() -elseif(RUNTIME_DIR_RELATIVE_TO_MANIFEST) - # Relative path to runtime. - set(RUNTIME_PATH ${RUNTIME_DIR_RELATIVE_TO_MANIFEST}/${RUNTIME_FILENAME}) -else() - # Unqualified runtime filename: requires it exist on the system shared library search path. - set(RUNTIME_PATH ${RUNTIME_FILENAME}) -endif() - -if(WIN32) - string(REPLACE "/" [[\\]] RUNTIME_PATH ${RUNTIME_PATH}) -endif() - -set(runtime_path ${RUNTIME_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/meson.build b/src/xrt/targets/openxr/meson.build index ad850f6fd..1365b982d 100644 --- a/src/xrt/targets/openxr/meson.build +++ b/src/xrt/targets/openxr/meson.build @@ -110,7 +110,7 @@ openxr = library( link_depends: mapfile ) -manifest_in = files('openxr_monado.in.json') +manifest_in = files('../../../../cmake/openxr_monado.in.json') manifest_conf = configuration_data() # https://github.com/mesonbuild/meson/issues/5941 diff --git a/src/xrt/targets/openxr/openxr_monado.in.json b/src/xrt/targets/openxr/openxr_monado.in.json deleted file mode 100644 index 72832291b..000000000 --- a/src/xrt/targets/openxr/openxr_monado.in.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "file_format_version": "1.0.0", - "runtime": { - "library_path": "@runtime_path@" - } -} diff --git a/src/xrt/targets/openxr/openxr_monado.in.json.license b/src/xrt/targets/openxr/openxr_monado.in.json.license deleted file mode 100644 index b426ba5ec..000000000 --- a/src/xrt/targets/openxr/openxr_monado.in.json.license +++ /dev/null @@ -1,2 +0,0 @@ -Copyright 2018-2020, Collabora, Ltd. -SPDX-License-Identifier: BSL-1.0