Default to statically linking OpenVR API directly from the public API source files.

This commit is contained in:
Christopher Bruns 2017-05-30 13:59:14 -04:00
parent 9db4dfd963
commit 857c183e5f

View file

@ -489,6 +489,13 @@ if (GZDOOM_USE_OPENVR)
${OPENVR_SDK_PATH}/headers ${OPENVR_SDK_PATH}/headers
) )
include_directories("${OPENVR_INCLUDE_DIRECTORY}") include_directories("${OPENVR_INCLUDE_DIRECTORY}")
option( GZDOOM_OPENVR_STATIC "Statically link OpenVR API" ON )
if(GZDOOM_OPENVR_STATIC)
# Incorporate the whole openvr API into zdoom, using a few rules lifted from the OpenVR CMakeLists.txt files
add_definitions( -DVR_API_PUBLIC )
include_directories(${OPENVR_SDK_PATH}/src ${OPENVR_SDK_PATH}/src/vrcommon)
file(GLOB OPENVR_SOURCES "${OPENVR_SDK_PATH}/src/*.cpp" "${OPENVR_SDK_PATH}/src/vrcommon/*.cpp")
else() # link to shared OpenVR library
# Link to correct library for this platform # Link to correct library for this platform
if(WIN32) if(WIN32)
set(OPENVR_PLAT "win") set(OPENVR_PLAT "win")
@ -507,7 +514,6 @@ if (GZDOOM_USE_OPENVR)
HINTS "${OPENVR_SDK_PATH}/lib/${OPENVR_PLAT}/" HINTS "${OPENVR_SDK_PATH}/lib/${OPENVR_PLAT}/"
) )
list(APPEND ZDOOM_LIBS ${OPENVR_LIBRARY}) list(APPEND ZDOOM_LIBS ${OPENVR_LIBRARY})
add_definitions("-DUSE_OPENVR")
# Find shared library file needed for package distribution # Find shared library file needed for package distribution
find_program(OPENVR_SHARED_LIBRARY find_program(OPENVR_SHARED_LIBRARY
NAMES libopenvr_api.so libopenvr_api.dylib openvr_api.dll NAMES libopenvr_api.so libopenvr_api.dylib openvr_api.dll
@ -515,6 +521,8 @@ if (GZDOOM_USE_OPENVR)
NO_DEFAULT_PATH NO_DEFAULT_PATH
) )
endif() endif()
add_definitions("-DUSE_OPENVR")
endif()
# Start defining source files for ZDoom # Start defining source files for ZDoom
set( PLAT_WIN32_SOURCES set( PLAT_WIN32_SOURCES
@ -1202,6 +1210,7 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE
${X86_SOURCES} ${X86_SOURCES}
${FASTMATH_SOURCES} ${FASTMATH_SOURCES}
${PCH_SOURCES} ${PCH_SOURCES}
${OPENVR_SOURCES}
x86.cpp x86.cpp
strnatcmp.c strnatcmp.c
zstring.cpp zstring.cpp