From 595c8a2fcb51a36b28bc2cfb97c9a85168775b19 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Wed, 12 Jan 2022 23:25:15 +0000 Subject: [PATCH] CMake: Fallback to built-in osgXR library Fall back to using the new built-in osgXR library in 3rdparty/ if no system library is provided and OpenXR is available. --- 3rdparty/CMakeLists.txt | 4 ++++ CMakeLists.txt | 26 +++++++++++++++++++++----- CMakeModules/SetupFGFSLibraries.cmake | 4 ++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index de17e1eec..2e7b90a23 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -29,3 +29,7 @@ endif() if (NOT SYSTEM_CPPUNIT) add_subdirectory(cppunit) endif() + +if (ENABLE_OSGXR AND NOT ENABLE_SYSTEM_OSGXR) + add_subdirectory(osgXR) +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index cb1705088..9d8e8153b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,6 +155,13 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR endif() endif() +if (ENABLE_VR_DEFAULT) + find_package(osgXR 0.3.3 QUIET) + if (osgXR_FOUND) + set(SYSTEM_OSGXR_DEFAULT 1) + endif() +endif() + # FlightGear build options option(LOGGING "Set to ON to build FlightGear with logging support (default)" ON) option(JSBSIM_TERRAIN "Set to ON to build FlightGear with JSBSim terrain handling code" ON) @@ -169,6 +176,7 @@ option(SYSTEM_SQLITE "Set to ON to build FlightGear with the system's SQLite option(ENABLE_IAX "Set to ON to build FlightGear with IAXClient/fgcom built-in (default)" ON) option(USE_DBUS "Set to ON to build FlightGear with DBus screensaver interaction (default on Linux)" ${USE_DBUS_DEFAULT}) option(ENABLE_VR "Set to ON to build Flightgear with VR support" ${ENABLE_VR_DEFAULT}) +option(SYSTEM_OSGXR "Set to ON to build Flightgear with the system's osgXR library" ${SYSTEM_OSGXR_DEFAULT}) option(SYSTEM_SPEEX "Set to ON to build IAXClient with the system's speex and speexdsp library" ${SYSTEM_SPEEX_DEFAULT}) option(SYSTEM_GSM "Set to ON to build IAXClient with the system's GSM library" ${SYSTEM_GSM_DEFAULT}) option(SYSTEM_FLITE "Set to ON to build Flightgear with the system's Flite library" ${SYSTEM_FLITE_DEFAULT}) @@ -301,13 +309,21 @@ endif (USE_DBUS) ############################################################################## ## VR setup if (ENABLE_VR) - find_package(osgXR 0.3.3 QUIET) - if (osgXR_FOUND) - message(STATUS "VR support enabled") + if (SYSTEM_OSGXR AND osgXR_FOUND) + message(STATUS "VR support enabled, using system osgXR library") + add_library(osgXR ALIAS osgXR::osgXR) set(ENABLE_OSGXR 1) + set(ENABLE_SYSTEM_OSGXR 1) else() - message(STATUS "VR support disabled, compatible osgXR library not found") - set(ENABLE_OSGXR 0) + find_package(OpenXR QUIET) + if (OpenXR_FOUND) + message(STATUS "VR support enabled, using built-in osgXR library") + set(ENABLE_OSGXR 1) + set(ENABLE_SYSTEM_OSGXR 0) + else() + message(STATUS "VR support disabled, OpenXR not found") + set(ENABLE_OSGXR 0) + endif() endif() else() message(STATUS "VR support disabled") diff --git a/CMakeModules/SetupFGFSLibraries.cmake b/CMakeModules/SetupFGFSLibraries.cmake index 8e69b8801..13344ec4f 100644 --- a/CMakeModules/SetupFGFSLibraries.cmake +++ b/CMakeModules/SetupFGFSLibraries.cmake @@ -24,7 +24,7 @@ function(setup_fgfs_libraries target) endif() if(ENABLE_OSGXR) - target_link_libraries(${target} osgXR::osgXR) + target_link_libraries(${target} osgXR) endif() target_link_libraries(${target} fgsqlite3 fgvoicesynth fgembeddedresources) @@ -118,7 +118,7 @@ function (setup_fgfs_library_includes target) endif() if(ENABLE_OSGXR) - _apply_target_includes(${target} osgXR::osgXR) + _apply_target_includes(${target} osgXR) endif() _apply_target_includes(${target} fgsqlite3)