Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2020-03-04 18:39:00 +0300
committerJulian Eisel <eiseljulian@gmail.com>2020-03-04 18:45:07 +0300
commita22573e243d7eeda7c10c9afc59377d474c74e5e (patch)
treecd50df07df955f1186c604aedc2222c1c0479638 /build_files
parente7f1de5e110a925cfa11bb7824c4fe2695e274ba (diff)
Build System: Add OpenXR-SDK dependency and WITH_XR_OPENXR build option
The OpenXR-SDK contains utilities for using the OpenXR standard (https://www.khronos.org/openxr/). Namely C-headers and a so called "loader" to manage runtime linking to OpenXR platforms ("runtimes") installed on the user's system. The WITH_XR_OPENXR build option is disabled by default for now, as there is no code using it yet. On macOS it will remain disabled for now, it's untested and there's no OpenXR runtime in sight for it. Some points on the OpenXR-SDK dependency: * The repository is located at https://github.com/KhronosGroup/OpenXR-SDK (Apache 2). * Notes on updating the dependency: https://wiki.blender.org/wiki/Source/OpenXR_SDK_Dependency * It contains a bunch of generated files, for which the sources are in a separate repository (https://github.com/KhronosGroup/OpenXR-SDK-Source). * We could use that other repo by default, but I'd rather go with the simpler solution and allow people to opt in if they want advanced dev features. * We currently use the OpenXR loader lib from it and the headers. * To use the injected OpenXR API-layers from the SDK (e.g. API validation layers), the SDK needs to be compiled from this other repository. The extra "XR_" prefix in the build option is to avoid mix-ups of OpenXR with OpenEXR. Most of this comes from the 2019 GSoC project, "Core Support of Virtual Reality Headsets through OpenXR" (https://wiki.blender.org/wiki/User:Severin/GSoC-2019/). Differential Revision: https://developer.blender.org/D6188 Reviewed by: Campbell Barton, Sergey Sharybin, Bastien Montagne, Ray Molenkamp
Diffstat (limited to 'build_files')
-rw-r--r--build_files/build_environment/CMakeLists.txt1
-rw-r--r--build_files/build_environment/cmake/harvest.cmake2
-rw-r--r--build_files/build_environment/cmake/versions.cmake4
-rw-r--r--build_files/build_environment/cmake/xr_openxr.cmake58
-rwxr-xr-xbuild_files/build_environment/install_deps.sh217
-rw-r--r--build_files/cmake/Modules/FindXR-OpenXR-SDK.cmake73
-rw-r--r--build_files/cmake/config/blender_full.cmake3
-rw-r--r--build_files/cmake/config/blender_lite.cmake1
-rw-r--r--build_files/cmake/config/blender_release.cmake3
-rw-r--r--build_files/cmake/platform/platform_apple.cmake8
-rw-r--r--build_files/cmake/platform/platform_unix.cmake8
-rw-r--r--build_files/cmake/platform/platform_win32.cmake12
12 files changed, 386 insertions, 4 deletions
diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt
index 34ad0599ce2..53d88b12129 100644
--- a/build_files/build_environment/CMakeLists.txt
+++ b/build_files/build_environment/CMakeLists.txt
@@ -99,6 +99,7 @@ else()
endif()
include(cmake/openimagedenoise.cmake)
include(cmake/embree.cmake)
+include(cmake/xr_openxr.cmake)
if(WITH_WEBP)
include(cmake/webp.cmake)
diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake
index 5fb62e330af..6801ef284d0 100644
--- a/build_files/build_environment/cmake/harvest.cmake
+++ b/build_files/build_environment/cmake/harvest.cmake
@@ -161,6 +161,8 @@ harvest(opensubdiv/include opensubdiv/include "*.h")
harvest(opensubdiv/lib opensubdiv/lib "*.a")
harvest(openvdb/include/openvdb openvdb/include/openvdb "*.h")
harvest(openvdb/lib openvdb/lib "*.a")
+harvest(xr_openxr_sdk/include/openxr xr_openxr_sdk/include/openxr "*.h")
+harvest(xr_openxr_sdk/lib xr_openxr_sdk/src/loader "*.a")
harvest(osl/bin osl/bin "oslc")
harvest(osl/include osl/include "*.h")
harvest(osl/lib osl/lib "*.a")
diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake
index 1f44601cd5a..af0d4e5571d 100644
--- a/build_files/build_environment/cmake/versions.cmake
+++ b/build_files/build_environment/cmake/versions.cmake
@@ -318,3 +318,7 @@ set(LIBGLU_HASH 151aef599b8259efe9acd599c96ea2a3)
set(MESA_VERSION 18.3.1)
set(MESA_URI ftp://ftp.freedesktop.org/pub/mesa//mesa-${MESA_VERSION}.tar.xz)
set(MESA_HASH d60828056d77bfdbae0970f9b15fb1be)
+
+set(XR_OPENXR_SDK_VERSION 1.0.6)
+set(XR_OPENXR_SDK_URI https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_SDK_VERSION}.tar.gz)
+set(XR_OPENXR_SDK_HASH 21daea7c3bfec365298d779a0e19caa1)
diff --git a/build_files/build_environment/cmake/xr_openxr.cmake b/build_files/build_environment/cmake/xr_openxr.cmake
new file mode 100644
index 00000000000..b0751e418b9
--- /dev/null
+++ b/build_files/build_environment/cmake/xr_openxr.cmake
@@ -0,0 +1,58 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+
+# Keep flags in sync with install_deps.sh ones in compile_XR_OpenXR_SDK()
+set(XR_OPENXR_SDK_EXTRA_ARGS
+ -DBUILD_FORCE_GENERATION=OFF
+ -DBUILD_LOADER=ON
+ -DDYNAMIC_LOADER=OFF
+)
+
+if(UNIX AND NOT APPLE)
+ list(APPEND XR_OPENXR_SDK_EXTRA_ARGS
+ -DBUILD_WITH_WAYLAND_HEADERS=OFF
+ -DBUILD_WITH_XCB_HEADERS=OFF
+ -DBUILD_WITH_XLIB_HEADERS=ON
+ )
+endif()
+
+ExternalProject_Add(external_xr_openxr_sdk
+ URL ${XR_OPENXR_SDK_URI}
+ DOWNLOAD_DIR ${DOWNLOAD_DIR}
+ URL_HASH MD5=${XR_OPENXR_SDK_HASH}
+ PREFIX ${BUILD_DIR}/xr_openxr_sdk
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/xr_openxr_sdk ${DEFAULT_CMAKE_FLAGS} ${XR_OPENXR_SDK_EXTRA_ARGS}
+ INSTALL_DIR ${LIBDIR}/xr_openxr_sdk
+)
+
+if(WIN32)
+ if(BUILD_MODE STREQUAL Release)
+ ExternalProject_Add_Step(external_xr_openxr_sdk after_install
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/xr_openxr_sdk/include/openxr ${HARVEST_TARGET}/xr_openxr_sdk/include/openxr
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/xr_openxr_sdk/lib ${HARVEST_TARGET}/xr_openxr_sdk/lib
+ DEPENDEES install
+ )
+ endif()
+ if(BUILD_MODE STREQUAL Debug)
+ ExternalProject_Add_Step(external_xr_openxr_sdk after_install
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/xr_openxr_sdk/lib/openxr_loader.lib ${HARVEST_TARGET}/xr_openxr_sdk/lib/openxr_loader_d.lib
+ DEPENDEES install
+ )
+ endif()
+endif()
diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh
index 0553f615805..df2866a0e2c 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -52,16 +52,19 @@ getopt \
-o s:i:t:h \
--long source:,install:,tmp:,info:,threads:,help,show-deps,no-sudo,no-build,no-confirm,\
with-all,with-opencollada,with-jack,with-embree,with-oidn,\
-ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,\
+ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,ver-osd:,ver-openvdb:,ver-xr-openxr:,\
force-all,force-python,force-numpy,force-boost,\
force-ocio,force-openexr,force-oiio,force-llvm,force-osl,force-osd,force-openvdb,\
force-ffmpeg,force-opencollada,force-alembic,force-embree,force-oidn,force-usd,\
+force-xr-openxr,\
build-all,build-python,build-numpy,build-boost,\
build-ocio,build-openexr,build-oiio,build-llvm,build-osl,build-osd,build-openvdb,\
build-ffmpeg,build-opencollada,build-alembic,build-embree,build-oidn,build-usd,\
+build-xr-openxr,\
skip-python,skip-numpy,skip-boost,\
skip-ocio,skip-openexr,skip-oiio,skip-llvm,skip-osl,skip-osd,skip-openvdb,\
-skip-ffmpeg,skip-opencollada,skip-alembic,skip-embree,skip-oidn,skip-usd \
+skip-ffmpeg,skip-opencollada,skip-alembic,skip-embree,skip-oidn,skip-usd, \
+skip-xr-openxr\
-- "$@" \
)
@@ -169,6 +172,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--ver-openvdb=<ver>
Force version of OpenVDB library.
+ --ver-xr-openxr=<ver>
+ Force version of OpenXR-SDK.
+
Note about the --ver-foo options:
It may not always work as expected (some libs are actually checked out from a git rev...), yet it might help
to fix some build issues (like LLVM mismatch with the version used by your graphic system).
@@ -224,6 +230,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--build-usd
Force the build of Universal Scene Description.
+ --build-xr-openxr
+ Force the build of OpenXR-SDK.
+
Note about the --build-foo options:
* They force the script to prefer building dependencies rather than using available packages.
This may make things simpler and allow working around some distribution bugs, but on the other hand it will
@@ -285,6 +294,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--force-usd
Force the rebuild of Universal Scene Description.
+ --force-xr-openxr
+ Force the rebuild of OpenXR-SDK.
+
Note about the --force-foo options:
* They obviously only have an effect if those libraries are built by this script
(i.e. if there is no available and satisfactory package)!
@@ -337,7 +349,10 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
Unconditionally skip FFMpeg installation/building.
--skip-usd
- Unconditionally skip Universal Scene Description installation/building.\""
+ Unconditionally skip Universal Scene Description installation/building.
+
+ --skip-xr-openxr
+ Unconditionally skip OpenXR-SDK installation/building.\""
# ----------------------------------------------------------------------------
# Main Vars
@@ -454,6 +469,11 @@ FFMPEG_FORCE_REBUILD=false
FFMPEG_SKIP=false
_ffmpeg_list_sep=";"
+XR_OPENXR_VERSION="1.0.6"
+XR_OPENXR_FORCE_BUILD=false
+XR_OPENXR_FORCE_REBUILD=false
+XR_OPENXR_SKIP=false
+
# FFMPEG optional libs.
VORBIS_USE=false
VORBIS_DEV=""
@@ -624,6 +644,11 @@ while true; do
OPENVDB_VERSION_MIN=$OPENVDB_VERSION
shift; shift; continue
;;
+ --ver-xr-openxr)
+ XR_OPENXR_VERSION="$2"
+ XR_OPENXR_VERSION_MIN=$XR_OPENXR_VERSION
+ shift; shift; continue
+ ;;
--build-all)
PYTHON_FORCE_BUILD=true
NUMPY_FORCE_BUILD=true
@@ -641,6 +666,7 @@ while true; do
FFMPEG_FORCE_BUILD=true
ALEMBIC_FORCE_BUILD=true
USD_FORCE_BUILD=true
+ XR_OPENXR_FORCE_BUILD=true
shift; continue
;;
--build-python)
@@ -695,6 +721,9 @@ while true; do
--build-usd)
USD_FORCE_BUILD=true; shift; continue
;;
+ --build-xr-openxr)
+ XR_OPENXR_FORCE_BUILD=true; shift; continue
+ ;;
--force-all)
PYTHON_FORCE_REBUILD=true
NUMPY_FORCE_REBUILD=true
@@ -712,6 +741,7 @@ while true; do
FFMPEG_FORCE_REBUILD=true
ALEMBIC_FORCE_REBUILD=true
USD_FORCE_REBUILD=true
+ XR_OPENXR_FORCE_REBUILD=true
shift; continue
;;
--force-python)
@@ -764,6 +794,9 @@ while true; do
--force-usd)
USD_FORCE_REBUILD=true; shift; continue
;;
+ --force-xr-openxr)
+ XR_OPENXR_FORCE_REBUILD=true; shift; continue
+ ;;
--skip-python)
PYTHON_SKIP=true; shift; continue
;;
@@ -812,6 +845,9 @@ while true; do
--skip-usd)
USD_SKIP=true; shift; continue
;;
+ --skip-xr-openxr)
+ XR_OPENXR_SKIP=true; shift; continue
+ ;;
--)
# no more arguments to parse
break
@@ -940,6 +976,12 @@ OIDN_SOURCE=( "https://github.com/OpenImageDenoise/oidn/releases/download/v${OID
FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
+XR_OPENXR_USE_REPO=false
+XR_OPENXR_SOURCE=("https://github.com/KhronosGroup/OpenXR-SDK/archive/release-${XR_OPENXR_VERSION}.tar.gz")
+#~ XR_OPENXR_SOURCE_REPO=("https://github.com/KhronosGroup/OpenXR-SDK-Source.git")
+#~ XR_OPENXR_REPO_UID="5292e57fda47561e672fba0a4b6e545c0f25dd8d"
+#~ XR_OPENXR_REPO_BRANCH="master"
+
# C++11 is required now
CXXFLAGS_BACK=$CXXFLAGS
CXXFLAGS="$CXXFLAGS -std=c++11"
@@ -982,7 +1024,8 @@ You may also want to build them yourself (optional ones are [between brackets]):
* [Embree $EMBREE_VERSION] (from $EMBREE_SOURCE).
* [OpenImageDenoise $OIDN_VERSION] (from $OIDN_SOURCE).
* [Alembic $ALEMBIC_VERSION] (from $ALEMBIC_SOURCE).
- * [Universal Scene Description $USD_VERSION] (from $USD_SOURCE).\""
+ * [Universal Scene Description $USD_VERSION] (from $USD_SOURCE).
+ * [OpenXR-SDK $XR_OPENXR_VERSION] (from $XR_OPENXR_SOURCE).\""
if [ "$DO_SHOW_DEPS" = true ]; then
PRINT ""
@@ -3058,6 +3101,116 @@ compile_FFmpeg() {
fi
}
+# ----------------------------------------------------------------------------
+# Build OpenXR SDK
+
+_init_xr_openxr_sdk() {
+ _src=$SRC/XR-OpenXR-SDK-$XR_OPENXR_VERSION
+ _git=true
+ _inst=$INST/xr-openxr-sdk-$XR_OPENXR_VERSION
+ _inst_shortcut=$INST/xr-openxr-sdk
+}
+
+_update_deps_xr_openxr_sdk() {
+ :
+}
+
+clean_XR_OpenXR_SDK() {
+ _init_xr_openxr_sdk
+ _clean
+ _update_deps_xr_openxr_sdk
+}
+
+compile_XR_OpenXR_SDK() {
+ if [ "$NO_BUILD" = true ]; then
+ WARNING "--no-build enabled, OpenXR will not be compiled!"
+ return
+ fi
+
+ # To be changed each time we make edits that would modify the compiled result!
+ xr_openxr_magic=0
+ _init_xr_openxr_sdk
+
+ # Clean install if needed!
+ magic_compile_check xr-openxr-$OPENXR_VERSION $xr_openxr_magic
+ if [ $? -eq 1 -o "$XR_OPENXR_FORCE_REBUILD" = true ]; then
+ clean_XR_OpenXR_SDK
+ fi
+
+ if [ ! -d $_inst ]; then
+ INFO "Building XR-OpenXR-SDK-$XR_OPENXR_VERSION"
+ _is_building=true
+
+ # Rebuild dependencies as well!
+ _update_deps_xr_openxr_sdk
+
+ prepare_opt
+
+ if [ ! -d $_src ]; then
+ mkdir -p $SRC
+
+ if [ "$XR_OPENXR_USE_REPO" = true ]; then
+ git clone $XR_OPENXR_SOURCE_REPO $_src
+ else
+ download XR_OPENXR_SOURCE[@] "$_src.tar.gz"
+ INFO "Unpacking XR-OpenXR-SDK-$XR_OPENXR_VERSION"
+ tar -C $SRC --transform "s,(.*/?)OpenXR-SDK-[^/]*(.*),\1XR-OpenXR-SDK-$XR_OPENXR_VERSION\2,x" \
+ -xf $_src.tar.gz
+ fi
+ fi
+
+ cd $_src
+
+ if [ "$XR_OPENXR_USE_REPO" = true ]; then
+ git pull origin $XR_OPENXR_REPO_BRANCH
+
+ # Stick to same rev as windows' libs...
+ git checkout $XR_OPENXR_REPO_UID
+ git reset --hard
+ fi
+
+ # Always refresh the whole build!
+ if [ -d build ]; then
+ rm -rf build
+ fi
+ mkdir build
+ cd build
+
+ # Keep flags in sync with XR_OPENXR_SDK_EXTRA_ARGS in xr_openxr.cmake!
+ cmake_d="-D CMAKE_BUILD_TYPE=Release"
+ cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
+ cmake_d="$cmake_d -D BUILD_FORCE_GENERATION=OFF"
+ cmake_d="$cmake_d -D BUILD_LOADER=ON"
+ cmake_d="$cmake_d -D DYNAMIC_LOADER=OFF"
+ cmake_d="$cmake_d -D BUILD_WITH_WAYLAND_HEADERS=OFF"
+ cmake_d="$cmake_d -D BUILD_WITH_XCB_HEADERS=OFF"
+ cmake_d="$cmake_d -D BUILD_WITH_XLIB_HEADERS=ON"
+
+ cmake $cmake_d ..
+
+ make -j$THREADS && make install
+ make clean
+
+ if [ -d $_inst ]; then
+ _create_inst_shortcut
+ else
+ ERROR "XR-OpenXR-SDK-$XR_OPENXR_VERSION failed to compile, exiting"
+ exit 1
+ fi
+
+ magic_compile_set xr-openxr-$XR_OPENXR_VERSION $xr_openxr_magic
+
+ cd $CWD
+ INFO "Done compiling XR-OpenXR-SDK-$XR_OPENXR_VERSION!"
+ _is_building=false
+ else
+ INFO "Own XR-OpenXR-SDK-$XR_OPENXR_VERSION is up to date, nothing to do!"
+ INFO "If you want to force rebuild of this lib, use the --force-xr-openxr option."
+ fi
+
+ run_ldconfig "xr-openxr-sdk"
+}
+
# ----------------------------------------------------------------------------
# Install on DEB-like
@@ -3602,6 +3755,18 @@ install_DEB() {
compile_FFmpeg
fi
fi
+
+ PRINT ""
+ if [ "$XR_OPENXR_SKIP" = true ]; then
+ WARNING "Skipping OpenXR-SDK installation, as requested..."
+ elif [ "$XR_OPENXR_FORCE_BUILD" = true ]; then
+ INFO "Forced OpenXR-SDK building, as requested..."
+ compile_XR_OpenXR_SDK
+ else
+ # No package currently!
+ PRINT ""
+ compile_XR_OpenXR_SDK
+ fi
}
@@ -4208,6 +4373,17 @@ install_RPM() {
compile_FFmpeg
fi
fi
+
+ PRINT ""
+ if [ "$XR_OPENXR_SKIP" = true ]; then
+ WARNING "Skipping OpenXR-SDK installation, as requested..."
+ elif [ "$XR_OPENXR_FORCE_BUILD" = true ]; then
+ INFO "Forced OpenXR-SDK building, as requested..."
+ compile_XR_OpenXR_SDK
+ else
+ # No package currently!
+ compile_XR_OpenXR_SDK
+ fi
}
@@ -4709,6 +4885,17 @@ install_ARCH() {
compile_FFmpeg
fi
fi
+
+ PRINT ""
+ if [ "$XR_OPENXR_SKIP" = true ]; then
+ WARNING "Skipping OpenXR-SDK installation, as requested..."
+ elif [ "$XR_OPENXR_FORCE_BUILD" = true ]; then
+ INFO "Forced OpenXR-SDK building, as requested..."
+ compile_XR_OpenXR_SDK
+ else
+ # No package currently!
+ compile_XR_OpenXR_SDK
+ fi
}
@@ -4906,6 +5093,17 @@ install_OTHER() {
INFO "Forced FFMpeg building, as requested..."
compile_FFmpeg
fi
+
+ PRINT ""
+ if [ "$XR_OPENXR_SKIP" = true ]; then
+ WARNING "Skipping OpenXR-SDK installation, as requested..."
+ elif [ "$XR_OPENXR_FORCE_BUILD" = true ]; then
+ INFO "Forced OpenXR-SDK building, as requested..."
+ compile_XR_OpenXR_SDK
+ else
+ # No package currently!
+ compile_XR_OpenXR_SDK
+ fi
}
# ----------------------------------------------------------------------------
@@ -5174,6 +5372,17 @@ print_info() {
fi
fi
+ if [ "$XR_OPENXR_SKIP" = false ]; then
+ _1="-D WITH_XR_OPENXR=ON"
+ PRINT " $_1"
+ _buildargs="$_buildargs $_1"
+ if [ -d $INST/xr-openxr-sdk ]; then
+ _1="-D XR_OPENXR_ROOT_DIR=$INST/xr-openxr-sdk"
+ PRINT " $_1"
+ _buildargs="$_buildargs $_1"
+ fi
+ fi
+
PRINT ""
PRINT "Or even simpler, just run (in your blender-source dir):"
PRINT " make -j$THREADS BUILD_CMAKE_ARGS=\"$_buildargs\""
diff --git a/build_files/cmake/Modules/FindXR-OpenXR-SDK.cmake b/build_files/cmake/Modules/FindXR-OpenXR-SDK.cmake
new file mode 100644
index 00000000000..71b40ec1bde
--- /dev/null
+++ b/build_files/cmake/Modules/FindXR-OpenXR-SDK.cmake
@@ -0,0 +1,73 @@
+# - Find OpenXR-SDK libraries
+# Find the native OpenXR-SDK includes and libraries
+#
+# Note that there is a distinction between the OpenXR standard and the SDK. The
+# latter provides utilities to use the standard but is not part of it. Most
+# importantly, it contains C headers and a loader library, which manages
+# dynamic linking to OpenXR runtimes like Monado, Windows Mixed Reality or
+# Oculus. See the repository for more details:
+# https://github.com/KhronosGroup/OpenXR-SDK
+#
+# This module defines
+# XR_OPENXR_SDK_INCLUDE_DIRS, where to find OpenXR-SDK headers, Set when
+# XR_OPENXR_SDK_INCLUDE_DIR is found.
+# XR_OPENXR_SDK_LIBRARIES, libraries to link against to use OpenXR.
+# XR_OPENXR_SDK_ROOT_DIR, the base directory to search for OpenXR-SDK.
+# This can also be an environment variable.
+# XR_OPENXR_SDK_FOUND, if false, do not try to use OpenXR-SDK.
+#
+# also defined, but not for general use are
+# XR_OPENXR_SDK_LOADER_LIBRARY, where to find the OpenXR-SDK loader library.
+
+#=============================================================================
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+# If XR_OPENXR_SDK_ROOT_DIR was defined in the environment, use it.
+IF(NOT XR_OPENXR_SDK_ROOT_DIR AND NOT $ENV{XR_OPENXR_SDK_ROOT_DIR} STREQUAL "")
+ SET(XR_OPENXR_SDK_ROOT_DIR $ENV{XR_OPENXR_SDK_ROOT_DIR})
+ENDIF()
+
+SET(_xr_openxr_sdk_SEARCH_DIRS
+ ${XR_OPENXR_SDK_ROOT_DIR}
+ /opt/lib/xr-openxr-sdk
+)
+
+FIND_PATH(XR_OPENXR_SDK_INCLUDE_DIR
+ NAMES
+ openxr/openxr.h
+ HINTS
+ ${_xr_openxr_sdk_SEARCH_DIRS}
+ PATH_SUFFIXES
+ include
+)
+
+FIND_LIBRARY(XR_OPENXR_SDK_LOADER_LIBRARY
+ NAMES
+ openxr_loader
+ HINTS
+ ${_xr_openxr_sdk_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib
+)
+
+# handle the QUIETLY and REQUIRED arguments and set XR_OPENXR_SDK_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(XR_OPENXR_SDK DEFAULT_MSG
+ XR_OPENXR_SDK_LOADER_LIBRARY XR_OPENXR_SDK_INCLUDE_DIR)
+
+IF(XR_OPENXR_SDK_FOUND)
+ SET(XR_OPENXR_SDK_LIBRARIES ${XR_OPENXR_SDK_LOADER_LIBRARY})
+ SET(XR_OPENXR_SDK_INCLUDE_DIRS ${XR_OPENXR_SDK_INCLUDE_DIR})
+ENDIF(XR_OPENXR_SDK_FOUND)
+
+MARK_AS_ADVANCED(
+ XR_OPENXR_SDK_INCLUDE_DIR
+ XR_OPENXR_SDK_LOADER_LIBRARY
+)
diff --git a/build_files/cmake/config/blender_full.cmake b/build_files/cmake/config/blender_full.cmake
index f5cfedc8ea7..a997d7c0e68 100644
--- a/build_files/cmake/config/blender_full.cmake
+++ b/build_files/cmake/config/blender_full.cmake
@@ -61,3 +61,6 @@ if(UNIX AND NOT APPLE)
set(WITH_X11_XINPUT ON CACHE BOOL "" FORCE)
set(WITH_X11_XF86VMODE ON CACHE BOOL "" FORCE)
endif()
+if(NOT APPLE)
+ set(WITH_XR_OPENXR ON CACHE BOOL "" FORCE)
+endif()
diff --git a/build_files/cmake/config/blender_lite.cmake b/build_files/cmake/config/blender_lite.cmake
index 77336dd20b9..7c94ce9d672 100644
--- a/build_files/cmake/config/blender_lite.cmake
+++ b/build_files/cmake/config/blender_lite.cmake
@@ -44,6 +44,7 @@ set(WITH_OPENAL OFF CACHE BOOL "" FORCE)
set(WITH_OPENCOLLADA OFF CACHE BOOL "" FORCE)
set(WITH_OPENCOLORIO OFF CACHE BOOL "" FORCE)
set(WITH_OPENIMAGEDENOISE OFF CACHE BOOL "" FORCE)
+set(WITH_XR_OPENXR OFF CACHE BOOL "" FORCE)
set(WITH_OPENIMAGEIO OFF CACHE BOOL "" FORCE)
set(WITH_OPENMP OFF CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV OFF CACHE BOOL "" FORCE)
diff --git a/build_files/cmake/config/blender_release.cmake b/build_files/cmake/config/blender_release.cmake
index 1a610ee45da..01a59e451aa 100644
--- a/build_files/cmake/config/blender_release.cmake
+++ b/build_files/cmake/config/blender_release.cmake
@@ -65,3 +65,6 @@ if(UNIX AND NOT APPLE)
set(WITH_X11_XINPUT ON CACHE BOOL "" FORCE)
set(WITH_X11_XF86VMODE ON CACHE BOOL "" FORCE)
endif()
+if(NOT APPLE)
+ set(WITH_XR_OPENXR ON CACHE BOOL "" FORCE)
+endif()
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index 123eb3ef7a0..11889fc7a87 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -421,6 +421,14 @@ if(WITH_OPENMP)
endif()
endif()
+if(WITH_XR_OPENXR)
+ find_package(OpenXR-SDK)
+ if(NOT OPENXR_SDK_FOUND)
+ message(WARNING "OpenXR-SDK was not found, disabling WITH_XR_OPENXR")
+ set(WITH_XR_OPENXR OFF)
+ endif()
+endif()
+
set(EXETYPE MACOSX_BUNDLE)
set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index 3b40f7c329b..dcb6b9d34f9 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -428,6 +428,14 @@ if(WITH_TBB)
find_package_wrapper(TBB)
endif()
+if(WITH_XR_OPENXR)
+ find_package(XR-OpenXR-SDK)
+ if(NOT XR_OPENXR_SDK_FOUND)
+ message(WARNING "OpenXR-SDK not found, disabling WITH_XR_OPENXR")
+ set(WITH_XR_OPENXR OFF)
+ endif()
+endif()
+
if(EXISTS ${LIBDIR})
without_system_libs_end()
endif()
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index 7ba7e3999e4..452deb497b2 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -713,3 +713,15 @@ if(WINDOWS_PYTHON_DEBUG)
</Project>")
endif()
endif()
+
+if(WITH_XR_OPENXR)
+ if(EXISTS ${LIBDIR}/xr_openxr_sdk)
+ set(XR_OPENXR_SDK ${LIBDIR}/xr_openxr_sdk)
+ set(XR_OPENXR_SDK_LIBPATH ${LIBDIR}/xr_openxr_sdk/lib)
+ set(XR_OPENXR_SDK_INCLUDE_DIR ${XR_OPENXR_SDK}/include)
+ set(XR_OPENXR_SDK_LIBRARIES optimized ${XR_OPENXR_SDK_LIBPATH}/openxr_loader.lib debug ${XR_OPENXR_SDK_LIBPATH}/openxr_loader_d.lib)
+ else()
+ message(WARNING "OpenXR-SDK was not found, disabling WITH_XR_OPENXR")
+ set(WITH_XR_OPENXR OFF)
+ endif()
+endif()