2019-03-18 05:52:32 +00:00
|
|
|
# Copyright 2019, Collabora, Ltd.
|
|
|
|
# SPDX-License-Identifier: BSL-1.0
|
|
|
|
|
|
|
|
######
|
|
|
|
# Create a loadable OpenXR driver.
|
|
|
|
|
|
|
|
# set(RUNTIME_BARE_PREFIX xrt)
|
|
|
|
# set(RUNTIME_PREFIX ${RUNTIME_BARE_PREFIX}_)
|
|
|
|
|
|
|
|
set(RUNTIME_BARE_SUFFIX monado)
|
|
|
|
set(RUNTIME_SUFFIX _${RUNTIME_BARE_SUFFIX})
|
|
|
|
|
|
|
|
set(RUNTIME_TARGET ${RUNTIME_PREFIX}openxr${RUNTIME_SUFFIX} CACHE INTERNAL "" FORCE)
|
|
|
|
|
|
|
|
set(XR_API_MAJOR "0")
|
|
|
|
|
|
|
|
|
|
|
|
# $LIBPATH is a generator expression that is evaluated after configure_file, so we have to use file(GENERATE) instead
|
|
|
|
|
|
|
|
###
|
|
|
|
# Generate runtime manifest with absolute path to runtime intended for development without installing
|
|
|
|
file(
|
|
|
|
GENERATE
|
|
|
|
OUTPUT "${CMAKE_BINARY_DIR}/${RUNTIME_TARGET}-dev.json"
|
|
|
|
CONTENT
|
|
|
|
"{
|
|
|
|
\"file_format_version\": \"1.0.0\",
|
|
|
|
\"runtime\": {
|
|
|
|
\"library_path\": \"$<TARGET_SONAME_FILE:${RUNTIME_TARGET}>\"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
")
|
|
|
|
|
|
|
|
###
|
|
|
|
# Generate runtime manifest with relative path to runtime intendend for installed release build
|
|
|
|
# (assumes the runtime library is in the loader's search path)
|
|
|
|
file(
|
|
|
|
GENERATE
|
|
|
|
OUTPUT "${CMAKE_BINARY_DIR}/${RUNTIME_TARGET}.json"
|
|
|
|
CONTENT
|
|
|
|
"{
|
|
|
|
\"file_format_version\": \"1.0.0\",
|
|
|
|
\"runtime\": {
|
|
|
|
\"library_path\": \"$<TARGET_SONAME_FILE_NAME:${RUNTIME_TARGET}>\"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
")
|
|
|
|
|
|
|
|
include_directories(
|
2019-04-15 08:51:40 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../../auxiliary
|
2019-03-18 05:52:32 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../../include
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../../drivers
|
|
|
|
)
|
|
|
|
|
|
|
|
set(SOURCE_FILES
|
|
|
|
target.c
|
|
|
|
)
|
|
|
|
|
|
|
|
# depends on above generated files
|
|
|
|
add_library(${RUNTIME_TARGET} SHARED
|
|
|
|
${MANIFEST_DEV_PATH}
|
|
|
|
${MANIFEST_PATH}
|
|
|
|
${SOURCE_FILES}
|
|
|
|
$<TARGET_OBJECTS:aux_util>
|
|
|
|
$<TARGET_OBJECTS:aux_math>
|
|
|
|
$<TARGET_OBJECTS:comp>
|
|
|
|
$<TARGET_OBJECTS:st_oxr>
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(${RUNTIME_TARGET}
|
2019-04-08 16:26:36 +00:00
|
|
|
PUBLIC
|
2019-03-18 05:52:32 +00:00
|
|
|
${Vulkan_LIBRARIES}
|
|
|
|
${XCB_LIBRARIES}
|
2019-03-23 03:09:53 +00:00
|
|
|
OpenGL::GLX
|
2019-03-18 05:52:32 +00:00
|
|
|
)
|
|
|
|
|
2019-04-20 01:24:09 +00:00
|
|
|
if(BUILD_DRIVER_HDK)
|
|
|
|
target_sources(${RUNTIME_TARGET} PRIVATE $<TARGET_OBJECTS:drv_hdk>)
|
|
|
|
target_link_libraries(${RUNTIME_TARGET} PUBLIC ${HIDAPI_LIBRARIES})
|
|
|
|
endif()
|
2019-03-18 05:52:32 +00:00
|
|
|
|
2019-04-29 16:18:09 +00:00
|
|
|
if(BUILD_DRIVER_OHMD)
|
2019-04-08 16:28:05 +00:00
|
|
|
target_sources(${RUNTIME_TARGET} PRIVATE $<TARGET_OBJECTS:drv_ohmd>)
|
2019-04-08 20:19:18 +00:00
|
|
|
target_link_libraries(${RUNTIME_TARGET} PRIVATE OpenHMD::OpenHMD)
|
2019-04-08 16:28:05 +00:00
|
|
|
endif()
|
|
|
|
|
2019-04-20 01:24:09 +00:00
|
|
|
if(BUILD_DRIVER_PSVR)
|
|
|
|
target_sources(${RUNTIME_TARGET} PRIVATE $<TARGET_OBJECTS:drv_psvr>)
|
2019-04-08 16:26:36 +00:00
|
|
|
target_link_libraries(${RUNTIME_TARGET} PUBLIC ${HIDAPI_LIBRARIES})
|
2019-03-18 05:52:32 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
install(TARGETS ${RUNTIME_TARGET}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
2019-04-08 18:44:20 +00:00
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/${RUNTIME_TARGET}.json" DESTINATION "share/openxr/${XR_API_MAJOR}/")
|
2019-03-18 05:52:32 +00:00
|
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
# TODO: install target on windows
|
|
|
|
endif()
|