From 94c5d2b9e85add3412169a93bd6f40a5f84c21e4 Mon Sep 17 00:00:00 2001 From: Joshua Brookover Date: Fri, 16 Sep 2016 01:21:37 -0500 Subject: [PATCH] OVR support via BGFX_USE_OVR --- CMakeLists.txt | 6 ++++++ cmake/bgfx.cmake | 6 +++++- cmake/ovr.cmake | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 cmake/ovr.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c3a74df..f66694d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,12 @@ endif() option( BGFX_BUILD_TOOLS "Build bgfx tools." ON ) option( BGFX_BUILD_EXAMPLES "Build bgfx examples." ON ) +option( BGFX_USE_OVR "Build with OVR support." OFF ) + +if( BGFX_USE_OVR ) + include( cmake/ovr.cmake ) +endif() + include( cmake/shared.cmake ) include( cmake/bx.cmake ) include( cmake/bgfx.cmake ) diff --git a/cmake/bgfx.cmake b/cmake/bgfx.cmake index 3665a32..0e353a3 100755 --- a/cmake/bgfx.cmake +++ b/cmake/bgfx.cmake @@ -40,6 +40,11 @@ target_include_directories( bgfx PUBLIC ${BGFX_DIR}/include ) # bgfx depends on bx target_link_libraries( bgfx PUBLIC bx ) +# ovr support +if( BGFX_USE_OVR ) + target_link_libraries( bgfx PUBLIC ovr ) +endif() + # Link against psapi in Visual Studio if( MSVC ) target_link_libraries( bgfx PUBLIC psapi ) @@ -61,7 +66,6 @@ endif() # Excluded files from compilation set_source_files_properties( ${BGFX_DIR}/src/amalgamated.cpp PROPERTIES HEADER_FILE_ONLY ON ) set_source_files_properties( ${BGFX_DIR}/src/amalgamated.mm PROPERTIES HEADER_FILE_ONLY ON ) -set_source_files_properties( ${BGFX_DIR}/src/hmd_ovr.cpp PROPERTIES HEADER_FILE_ONLY ON ) set_source_files_properties( ${BGFX_DIR}/src/glcontext_ppapi.cpp PROPERTIES HEADER_FILE_ONLY ON ) set_source_files_properties( ${BGFX_DIR}/src/glcontext_glx.cpp PROPERTIES HEADER_FILE_ONLY ON ) set_source_files_properties( ${BGFX_DIR}/src/glcontext_egl.cpp PROPERTIES HEADER_FILE_ONLY ON ) diff --git a/cmake/ovr.cmake b/cmake/ovr.cmake new file mode 100644 index 0000000..3854e9d --- /dev/null +++ b/cmake/ovr.cmake @@ -0,0 +1,47 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2016 by Joshua Brookover + +# To the extent possible under law, the author(s) have dedicated all copyright +# and related and neighboring rights to this software to the public domain +# worldwide. This software is distributed without any warranty. + +# You should have received a copy of the CC0 Public Domain Dedication along with +# this software. If not, see . + +# The ovr location is customizable via cache variable BGFX_OVR_DIR +if( NOT BGFX_OVR_DIR ) + set( BGFX_OVR_DIR "${CMAKE_CURRENT_SOURCE_DIR}/LibOVR" CACHE STRING "Location of LibOVR." ) +endif() + +# Ensure the directory exists +if( NOT IS_DIRECTORY ${BGFX_OVR_DIR} ) + message( SEND_ERROR "Could not load LibOVR, directory does not exist. ${BGFX_OVR_DIR}" ) + return() +endif() + +# Create the ovr target +add_library( ovr INTERFACE ) + +# Add include directory of ovr +target_include_directories( ovr INTERFACE ${BGFX_OVR_DIR}/Include ) + +# Add bgfx configuration define +target_compile_definitions( ovr INTERFACE "BGFX_CONFIG_USE_OVR=1" ) + +# Build system specific configurations +if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) + set( ARCH "x64" ) +else() + set( ARCH "Win32" ) +endif() +if( MSVC10 ) + target_link_libraries( ovr INTERFACE ${BGFX_OVR_DIR}/Lib/Windows/${ARCH}/Release/VS2010/LibOVR.lib ) +elseif( MSVC11 ) + target_link_libraries( ovr INTERFACE ${BGFX_OVR_DIR}/Lib/Windows/${ARCH}/Release/VS2012/LibOVR.lib ) +elseif( MSVC12 ) + target_link_libraries( ovr INTERFACE ${BGFX_OVR_DIR}/Lib/Windows/${ARCH}/Release/VS2013/LibOVR.lib ) +elseif( MSVC14 ) + target_link_libraries( ovr INTERFACE ${BGFX_OVR_DIR}/Lib/Windows/${ARCH}/Release/VS2015/LibOVR.lib ) +else() + message( STATUS "OVR not supported on this platform." ) +endif()