mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-10-04 20:56:32 +00:00
Use FetchContent feature of CMake to include openxr dependency instead of the old way.
This commit is contained in:
parent
01b7e9da25
commit
cdb8505f1d
3 changed files with 37 additions and 60 deletions
|
@ -77,7 +77,6 @@ BULLET_DOUBLE=""
|
|||
BULLET_DBL=""
|
||||
BULLET_DBL_DISPLAY="Single precision"
|
||||
SKIP_VR=""
|
||||
OPENXR_INSTALL_ROOT=""
|
||||
|
||||
ACTIVATE_MSVC=""
|
||||
SINGLE_CONFIG=""
|
||||
|
@ -97,9 +96,9 @@ while [ $# -gt 0 ]; do
|
|||
case $ARG in
|
||||
V )
|
||||
VERBOSE=true ;;
|
||||
|
||||
nVR )
|
||||
SKIP_VR=true ;;
|
||||
|
||||
nVR )
|
||||
SKIP_VR=true ;;
|
||||
|
||||
d )
|
||||
SKIP_DOWNLOAD=true ;;
|
||||
|
@ -516,16 +515,6 @@ if [ -z $SKIP_DOWNLOAD ]; then
|
|||
git clone -b release-1.10.0 https://github.com/google/googletest.git
|
||||
fi
|
||||
fi
|
||||
|
||||
# OpenXR
|
||||
if [ -z $SKIP_VR]; then
|
||||
echo "OpenXR SDK 1.0.9..."
|
||||
if [ -d OpenXR-SDK ]; then
|
||||
printf "OpenXR SDK exists, skipping."
|
||||
else
|
||||
git clone -b release-1.0.9 https://github.com/KhronosGroup/OpenXR-SDK.git
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
cd .. #/..
|
||||
|
@ -834,12 +823,6 @@ printf "SDL 2.0.12... "
|
|||
cd $DEPS
|
||||
echo
|
||||
|
||||
if [ $CONFIGURATION == "Debug" ]; then
|
||||
DEBUG_SUFFIX="d"
|
||||
else
|
||||
DEBUG_SUFFIX=""
|
||||
fi
|
||||
|
||||
# Google Test and Google Mock
|
||||
if [ ! -z $TEST_FRAMEWORK ]; then
|
||||
printf "Google test 1.10.0 ..."
|
||||
|
@ -852,6 +835,11 @@ if [ ! -z $TEST_FRAMEWORK ]; then
|
|||
cd build
|
||||
|
||||
GOOGLE_INSTALL_ROOT="${DEPS_INSTALL}/GoogleTest"
|
||||
if [ $CONFIGURATION == "Debug" ]; then
|
||||
DEBUG_SUFFIX="d"
|
||||
else
|
||||
DEBUG_SUFFIX=""
|
||||
fi
|
||||
|
||||
if [ ! -d $GOOGLE_INSTALL_ROOT ]; then
|
||||
|
||||
|
@ -879,29 +867,9 @@ if [ ! -z $TEST_FRAMEWORK ]; then
|
|||
|
||||
fi
|
||||
|
||||
# OpenXR SDK
|
||||
if [ -Z $SKIP_VR ]; then
|
||||
printf "OpenXR SDK 1.0.9 ..."
|
||||
|
||||
cd OpenXR-SDK
|
||||
if [ ! -d build ]; then
|
||||
mkdir -p build
|
||||
fi
|
||||
|
||||
cd build
|
||||
OPENXR_INSTALL_ROOT="${DEPS_INSTALL}/OpenXR-SDK"
|
||||
if [ ! -d $OPENXR_INSTALL_ROOT ]; then
|
||||
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${OPENXR_INSTALL_ROOT}" -G "${GENERATOR}" -DDYNAMIC_LOADER=ON
|
||||
cmake --build . --config Release
|
||||
cmake --build . --target install --config Release
|
||||
fi
|
||||
|
||||
add_runtime_dlls "${OPENXR_INSTALL_ROOT}\bin\openxr_loader.dll"
|
||||
|
||||
add_cmake_opts -DBUILD_VR_OPENXR=on
|
||||
add_cmake_opts -DOPENXR_ROOT="${OPENXR_INSTALL_ROOT}"
|
||||
add_cmake_opts -DOPENXR_LIBRARY="${OPENXR_INSTALL_ROOT}/lib/openxr_loader.lib"
|
||||
# VR build
|
||||
if [ ! -Z $SKIP_VR ]; then
|
||||
add_cmake_opts -DBUILD_VR_OPENXR=no
|
||||
fi
|
||||
|
||||
echo
|
||||
|
@ -919,6 +887,7 @@ if [ ! -z $CI ]; then
|
|||
-DBUILD_MWINIIMPORTER=no \
|
||||
-DBUILD_OPENCS=no \
|
||||
-DBUILD_OPENMW=no \
|
||||
-DBUILD_OPENMW_VR=no \
|
||||
-DBUILD_WIZARD=no
|
||||
;;
|
||||
openmw )
|
||||
|
@ -927,6 +896,7 @@ if [ ! -z $CI ]; then
|
|||
-DBUILD_LAUNCHER=no \
|
||||
-DBUILD_MWINIIMPORTER=no \
|
||||
-DBUILD_OPENCS=no \
|
||||
-DBUILD_OPENMW_VR=no \
|
||||
-DBUILD_WIZARD=no
|
||||
;;
|
||||
vr )
|
||||
|
@ -943,12 +913,14 @@ if [ ! -z $CI ]; then
|
|||
-DBUILD_LAUNCHER=no \
|
||||
-DBUILD_MWINIIMPORTER=no \
|
||||
-DBUILD_OPENMW=no \
|
||||
-DBUILD_OPENMW_VR=no \
|
||||
-DBUILD_WIZARD=no
|
||||
;;
|
||||
misc )
|
||||
echo " Building subprojects: Misc."
|
||||
add_cmake_opts -DBUILD_OPENCS=no \
|
||||
-DBUILD_OPENMW=no
|
||||
-DBUILD_OPENMW=no \
|
||||
-DBUILD_OPENMW_VR=no
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
|
|
@ -9,7 +9,7 @@ option(BUILD_BSATOOL "Build BSA extractor" ON)
|
|||
option(BUILD_ESMTOOL "Build ESM inspector" ON)
|
||||
option(BUILD_NIFTEST "Build nif file tester" ON)
|
||||
option(BUILD_DOCS "Build documentation." OFF )
|
||||
option(BUILD_VR_OPENXR "Build VR support using OpenXR" OFF)
|
||||
option(BUILD_OPENMW_VR "Build VR support using OpenXR" ON)
|
||||
option(BUILD_WITH_CODE_COVERAGE "Enable code coverage with gconv" OFF)
|
||||
option(BUILD_UNITTESTS "Enable Unittests with Google C++ Unittest" OFF)
|
||||
option(BULLET_USE_DOUBLES "Use double precision for Bullet" OFF)
|
||||
|
@ -21,7 +21,7 @@ else()
|
|||
endif()
|
||||
|
||||
# set the minimum required version across the board
|
||||
cmake_minimum_required(VERSION 3.1.0)
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
project(OpenMW)
|
||||
|
||||
|
@ -315,11 +315,6 @@ include_directories("."
|
|||
${BULLET_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
if(BUILD_VR_OPENXR)
|
||||
include_directories(${OPENXR_ROOT}/include)
|
||||
link_directories(${OPENXR_ROOT}/lib)
|
||||
endif(BUILD_VR_OPENXR)
|
||||
|
||||
link_directories(${SDL2_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS})
|
||||
|
||||
if(MYGUI_STATIC)
|
||||
|
@ -587,7 +582,7 @@ add_subdirectory (components)
|
|||
target_compile_definitions(components PRIVATE OPENMW_DOC_BASEURL="${OPENMW_DOC_BASEURL}")
|
||||
|
||||
# Apps and tools
|
||||
if (BUILD_OPENMW OR BUILD_VR_OPENXR)
|
||||
if (BUILD_OPENMW OR BUILD_OPENMW_VR)
|
||||
add_subdirectory( apps/openmw )
|
||||
endif()
|
||||
|
||||
|
@ -657,17 +652,17 @@ if (WIN32)
|
|||
endif()
|
||||
|
||||
# TODO: properties and link targets should be copied from openmw to openmw_vr instead of duplicating every line
|
||||
if (USE_DEBUG_CONSOLE AND BUILD_VR_OPENXR)
|
||||
if (USE_DEBUG_CONSOLE AND BUILD_OPENMW_VR)
|
||||
set_target_properties(openmw_vr PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
|
||||
set_target_properties(openmw_vr PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
|
||||
set_target_properties(openmw_vr PROPERTIES COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_CONSOLE>)
|
||||
elseif (BUILD_VR_OPENXR)
|
||||
elseif (BUILD_OPENMW_VR)
|
||||
# Turn off debug console, debug output will be written to visual studio output instead
|
||||
set_target_properties(openmw_vr PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
|
||||
set_target_properties(openmw_vr PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS")
|
||||
endif()
|
||||
|
||||
if (BUILD_VR_OPENXR)
|
||||
if (BUILD_OPENMW_VR)
|
||||
# Release builds don't use the debug console
|
||||
set_target_properties(openmw_vr PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
|
||||
set_target_properties(openmw_vr PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
|
||||
|
@ -773,7 +768,7 @@ if (WIN32)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
if (BUILD_VR_OPENXR)
|
||||
if (BUILD_OPENMW_VR)
|
||||
if (OPENMW_UNITY_BUILD)
|
||||
set_target_properties(openmw_vr PROPERTIES COMPILE_FLAGS "${WARNINGS} ${MT_BUILD} /bigobj")
|
||||
else()
|
||||
|
|
|
@ -235,9 +235,8 @@ if(BUILD_OPENMW)
|
|||
endif (WIN32)
|
||||
endif()
|
||||
|
||||
if(BUILD_VR_OPENXR)
|
||||
# TODO: Move this into something akin to add_openmw_dir instead of breaking pattern.
|
||||
# Later, openmw and openmw_vr should preferrably share game code as a static or shared library
|
||||
if(BUILD_OPENMW_VR)
|
||||
# TODO: Openmw and openmw_vr should preferrably share game code as a static or shared library
|
||||
# instead of being compiled separately, though for now that's not possible as i depend on
|
||||
# USE_OPENXR preprocessor switches.
|
||||
set(OPENMW_VR_FILES
|
||||
|
@ -255,10 +254,21 @@ if(BUILD_VR_OPENXR)
|
|||
${GAME} ${GAME_HEADER}
|
||||
${APPLE_BUNDLE_RESOURCES}
|
||||
)
|
||||
|
||||
# Import the OpenXR SDK
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
OpenXR
|
||||
GIT_REPOSITORY https://github.com/KhronosGroup/OpenXR-SDK.git
|
||||
GIT_TAG release-1.0.9
|
||||
)
|
||||
FetchContent_MakeAvailable(OpenXR)
|
||||
target_link_libraries(openmw_vr openxr_loader)
|
||||
target_include_directories(openmw_vr PRIVATE ${openxr_SOURCE_DIR}/include)
|
||||
|
||||
# Preprocessor variable used to control code paths to vr code
|
||||
target_compile_options(openmw_vr PUBLIC -DUSE_OPENXR -DXR_USE_GRAPHICS_API_OPENGL -DXR_USE_PLATFORM_WIN32)
|
||||
target_link_libraries(openmw_vr ${OPENMW_LINK_TARGETS} ${OPENXR_LIBRARY})
|
||||
target_link_libraries(openmw_vr ${OPENMW_LINK_TARGETS})
|
||||
if(APPLE)
|
||||
add_custom_command(TARGET openmw_vr
|
||||
POST_BUILD
|
||||
|
|
Loading…
Reference in a new issue