Build OpenVR plugin on Linux

This commit is contained in:
David Rowe 2020-05-23 14:53:43 +12:00
parent a9b56b5f3a
commit b72d5bf80c
4 changed files with 53 additions and 20 deletions

View file

@ -1,4 +1,4 @@
Source: hifi-client-deps
Version: 0.1
Description: Collected dependencies for High Fidelity applications
Build-Depends: hifi-deps, aristo (windows), glslang, liblo (windows), nlohmann-json, openvr (windows), quazip (!android), sdl2 (!android), spirv-cross (!android), spirv-tools (!android), sranipal (windows), vulkanmemoryallocator
Build-Depends: hifi-deps, aristo (windows), glslang, liblo (windows), nlohmann-json, openvr (linux), openvr (windows), quazip (!android), sdl2 (!android), spirv-cross (!android), spirv-tools (!android), sranipal (windows), vulkanmemoryallocator

View file

@ -11,15 +11,23 @@ vcpkg_from_github(
set(VCPKG_LIBRARY_LINKAGE dynamic)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(ARCH_PATH "win64")
if(WIN32)
set(ARCH_PATH "win64")
else()
set(ARCH_PATH "linux64")
endif()
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(ARCH_PATH "win32")
if(WIN32)
set(ARCH_PATH "win32")
else()
set(ARCH_PATH "linux32")
endif()
else()
message(FATAL_ERROR "Package only supports x64 and x86 windows.")
message(FATAL_ERROR "Package only supports x64 and x86 Windows and Linux.")
endif()
if(VCPKG_CMAKE_SYSTEM_NAME)
message(FATAL_ERROR "Package only supports windows desktop.")
if(VCPKG_CMAKE_SYSTEM_NAME AND NOT (VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux"))
message(FATAL_ERROR "Package only supports Windows or Linux desktop.")
endif()
file(MAKE_DIRECTORY
@ -28,18 +36,35 @@ file(MAKE_DIRECTORY
${CURRENT_PACKAGES_DIR}/debug/lib
${CURRENT_PACKAGES_DIR}/debug/bin
)
file(COPY ${SOURCE_PATH}/lib/${ARCH_PATH}/openvr_api.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
file(COPY ${SOURCE_PATH}/lib/${ARCH_PATH}/openvr_api.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
file(COPY
${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.dll
${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.pdb
DESTINATION ${CURRENT_PACKAGES_DIR}/bin
)
file(COPY
${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.dll
${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.pdb
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin
)
if(WIN32)
file(COPY ${SOURCE_PATH}/lib/${ARCH_PATH}/openvr_api.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
file(COPY ${SOURCE_PATH}/lib/${ARCH_PATH}/openvr_api.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
file(COPY
${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.dll
${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.pdb
DESTINATION ${CURRENT_PACKAGES_DIR}/bin
)
file(COPY
${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.dll
${SOURCE_PATH}/bin/${ARCH_PATH}/openvr_api.pdb
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin
)
else()
file(COPY ${SOURCE_PATH}/lib/${ARCH_PATH}/libopenvr_api.so DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
file(COPY ${SOURCE_PATH}/lib/${ARCH_PATH}/libopenvr_api.so DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
file(COPY
${SOURCE_PATH}/bin/${ARCH_PATH}/libopenvr_api.so
${SOURCE_PATH}/bin/${ARCH_PATH}/libopenvr_api.so.dbg
DESTINATION ${CURRENT_PACKAGES_DIR}/bin
)
file(COPY
${SOURCE_PATH}/bin/${ARCH_PATH}/libopenvr_api.so
${SOURCE_PATH}/bin/${ARCH_PATH}/libopenvr_api.so.dbg
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin
)
endif()
file(COPY ${SOURCE_PATH}/headers DESTINATION ${CURRENT_PACKAGES_DIR})
file(RENAME ${CURRENT_PACKAGES_DIR}/headers ${CURRENT_PACKAGES_DIR}/include)

View file

@ -6,7 +6,7 @@
# See the accompanying file LICENSE or http:#www.apache.org/licenses/LICENSE-2.0.html
#
if (WIN32 AND (NOT USE_GLES))
if ((WIN32 OR UNIX) AND (NOT USE_GLES))
set(TARGET_NAME openvr)
setup_hifi_plugin(Gui Qml Multimedia)
link_hifi_libraries(shared task gl qml networking controllers ui
@ -15,5 +15,7 @@ if (WIN32 AND (NOT USE_GLES))
include_hifi_library_headers(octree)
target_openvr()
target_link_libraries(${TARGET_NAME} Winmm.lib)
if (WIN32)
target_link_libraries(${TARGET_NAME} Winmm.lib)
endif()
endif()

View file

@ -739,6 +739,8 @@ int OpenVrDisplayPlugin::getRequiredThreadCount() const {
QString OpenVrDisplayPlugin::getPreferredAudioInDevice() const {
QString device = getVrSettingString(vr::k_pch_audio_Section, vr::k_pch_audio_RecordingDeviceOverride_String);
// FIXME: Address Linux.
#ifdef Q_OS_WIN
if (!device.isEmpty()) {
static const WCHAR INIT = 0;
size_t size = device.size() + 1;
@ -748,11 +750,14 @@ QString OpenVrDisplayPlugin::getPreferredAudioInDevice() const {
// FIXME: This may not be necessary if vr::k_pch_audio_RecordingDeviceOverride_StringName is used above.
device = AudioClient::getWinDeviceName(deviceW.data());
}
#endif
return device;
}
QString OpenVrDisplayPlugin::getPreferredAudioOutDevice() const {
QString device = getVrSettingString(vr::k_pch_audio_Section, vr::k_pch_audio_PlaybackDeviceOverride_String);
// FIXME: Address Linux.
#ifdef Q_OS_WIN
if (!device.isEmpty()) {
static const WCHAR INIT = 0;
size_t size = device.size() + 1;
@ -762,6 +767,7 @@ QString OpenVrDisplayPlugin::getPreferredAudioOutDevice() const {
// FIXME: This may not be necessary if vr::k_pch_audio_PlaybackDeviceOverride_StringName is used above.
device = AudioClient::getWinDeviceName(deviceW.data());
}
#endif
return device;
}