xrt: Move OpenXR defines to header

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2194>
This commit is contained in:
Christoph Haag 2024-05-26 22:36:40 +02:00 committed by Marge Bot
parent 8b2571b6ac
commit 8dd24bf28a
4 changed files with 64 additions and 23 deletions

View file

@ -31,3 +31,44 @@ configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/xrt_config_android.h.cmake_in
${CMAKE_CURRENT_BINARY_DIR}/xrt_config_android.h @ONLY
)
if(XRT_HAVE_VULKAN)
set(XR_USE_GRAPHICS_API_VULKAN ON)
endif()
if(XRT_HAVE_OPENGL)
set(XR_USE_GRAPHICS_API_OPENGL ON)
endif()
if(XRT_HAVE_OPENGLES)
set(XR_USE_GRAPHICS_API_OPENGL_ES ON)
endif()
if(XRT_HAVE_OPENGL_GLX AND XRT_HAVE_XLIB)
set(XR_USE_PLATFORM_XLIB ON)
endif()
if(XRT_HAVE_EGL)
set(XR_USE_PLATFORM_EGL ON)
endif()
if(XRT_HAVE_D3D11)
set(XR_USE_GRAPHICS_API_D3D11 ON)
endif()
if(XRT_HAVE_D3D12)
set(XR_USE_GRAPHICS_API_D3D12 ON)
endif()
if(ANDROID)
set(XR_USE_PLATFORM_ANDROID ON)
endif()
if(WIN32)
set(XR_USE_PLATFORM_WIN32 ON)
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/xrt_openxr_config.h.cmake_in
${CMAKE_CURRENT_BINARY_DIR}/xrt_openxr_config.h @ONLY
)

View file

@ -0,0 +1,20 @@
// Copyright 2024, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief What OpenXR defines are enabled in this oxr build.
* @author Christoph Haag <christoph.haag@collabora.com>
* @ingroup xrt_iface
*/
#pragma once
#cmakedefine XR_USE_GRAPHICS_API_VULKAN
#cmakedefine XR_USE_GRAPHICS_API_OPENGL
#cmakedefine XR_USE_GRAPHICS_API_OPENGL_ES
#cmakedefine XR_USE_PLATFORM_EGL
#cmakedefine XR_USE_PLATFORM_XLIB
#cmakedefine XR_USE_GRAPHICS_API_D3D11
#cmakedefine XR_USE_GRAPHICS_API_D3D12
#cmakedefine XR_USE_PLATFORM_ANDROID
#cmakedefine XR_USE_PLATFORM_WIN32

View file

@ -10,6 +10,8 @@
#pragma once
#include "xrt/xrt_openxr_config.h"
//! @todo Move these to the build system instead.
#define XR_USE_TIMESPEC 1

View file

@ -53,33 +53,21 @@ add_library(
oxr_xdev.c
)
set(OXR_COMPILE_DEFINITIONS)
if(XRT_HAVE_VULKAN)
list(APPEND OXR_COMPILE_DEFINITIONS XR_USE_GRAPHICS_API_VULKAN)
target_sources(st_oxr PRIVATE oxr_session_gfx_vk.c oxr_swapchain_vk.c oxr_vulkan.c)
target_link_libraries(st_oxr PUBLIC Vulkan::Vulkan)
endif()
if(XRT_HAVE_OPENGL)
list(APPEND OXR_COMPILE_DEFINITIONS XR_USE_GRAPHICS_API_OPENGL)
endif()
if(XRT_HAVE_OPENGLES)
list(APPEND OXR_COMPILE_DEFINITIONS XR_USE_GRAPHICS_API_OPENGL_ES)
endif()
if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES)
target_sources(st_oxr PRIVATE oxr_swapchain_gl.c)
target_link_libraries(st_oxr PUBLIC aux_ogl)
endif()
if(XRT_HAVE_OPENGL_GLX AND XRT_HAVE_XLIB)
list(APPEND OXR_COMPILE_DEFINITIONS XR_USE_PLATFORM_XLIB)
target_sources(st_oxr PRIVATE oxr_session_gfx_gl_xlib.c)
endif()
if(XRT_HAVE_EGL)
list(APPEND OXR_COMPILE_DEFINITIONS XR_USE_PLATFORM_EGL)
target_sources(st_oxr PRIVATE oxr_session_gfx_egl.c)
endif()
@ -89,34 +77,27 @@ if(XRT_HAVE_D3D11 OR XRT_HAVE_D3D12)
endif()
if(XRT_HAVE_D3D11)
list(APPEND OXR_COMPILE_DEFINITIONS XR_USE_GRAPHICS_API_D3D11)
target_sources(st_oxr PRIVATE oxr_session_gfx_d3d11.c oxr_swapchain_d3d11.c oxr_d3d11.cpp)
endif()
if(XRT_HAVE_D3D12)
list(APPEND OXR_COMPILE_DEFINITIONS XR_USE_GRAPHICS_API_D3D12)
target_sources(st_oxr PRIVATE oxr_session_gfx_d3d12.c oxr_swapchain_d3d12.c oxr_d3d12.cpp)
target_link_libraries(st_oxr PRIVATE aux_d3d)
endif()
if(ANDROID)
list(APPEND OXR_COMPILE_DEFINITIONS XR_USE_PLATFORM_ANDROID)
target_sources(st_oxr PRIVATE oxr_session_gfx_gles_android.c)
target_link_libraries(st_oxr PRIVATE aux_android)
endif()
if(WIN32)
target_link_libraries(st_oxr PRIVATE kernel32)
list(APPEND OXR_COMPILE_DEFINITIONS XR_USE_PLATFORM_WIN32)
endif()
if(WIN32 AND XRT_HAVE_OPENGL)
target_sources(st_oxr PRIVATE oxr_session_gfx_gl_win32.c)
endif()
if(WIN32)
list(APPEND OXR_COMPILE_DEFINITIONS XR_USE_PLATFORM_WIN32)
endif()
if(XRT_FEATURE_OPENXR_LAYER_PASSTHROUGH)
target_sources(st_oxr PRIVATE oxr_api_passthrough.c oxr_passthrough.c)
endif()
@ -129,9 +110,6 @@ if(XRT_FEATURE_OPENXR_FACIAL_TRACKING_HTC)
target_sources(st_oxr PRIVATE oxr_api_face_tracking.c oxr_face_tracking.c)
endif()
target_compile_definitions(st_oxr PRIVATE ${OXR_COMPILE_DEFINITIONS})
target_compile_definitions(oxr-interfaces INTERFACE ${OXR_COMPILE_DEFINITIONS})
target_link_libraries(
st_oxr
PRIVATE