cmake: Substantial cleanups and simplifications

We now have a cmake-format config file.
We no longer use list variables for sources, instead using
target_sources when we need to add, in accordance with current
best practice. (This makes it a lot easier to edit too.) There's no more
include_directories(), add_definitions(), or other gently-deprecated
directory-scoped commands, nor any CMake scripts that include
a parent directory reference (named targets instead)
This commit is contained in:
Ryan Pavlik 2021-11-11 17:41:58 -06:00
parent 19947a2d27
commit cc4007a69e
29 changed files with 1018 additions and 1082 deletions

23
.cmake-format.py Normal file
View file

@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: 2021, Collabora, Ltd.
# SPDX-License-Identifier: CC0-1.0
with section("format"):
line_width = 100
tab_size = 8
use_tabchars = True
fractional_tab_policy = "use-space"
max_prefix_chars = 4
dangle_parens = True
dangle_align = "prefix-indent"
max_pargs_hwrap = 4
max_rows_cmdline = 1
keyword_case = 'upper'
# Do not reflow comments
with section("markup"):
enable_markup = False

View file

@ -9,7 +9,11 @@ if(POLICY CMP0072)
cmake_policy(SET CMP0072 NEW)
endif()
option(XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH "Use the absolute path to the runtime in the installed manifest, rather than a bare filename." ON)
option(
XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH
"Use the absolute path to the runtime in the installed manifest, rather than a bare filename."
ON
)
option(XRT_OPENXR_INSTALL_ACTIVE_RUNTIME "Make Monado the default OpenXR runtime on install" ON)
# We use C++17
@ -45,7 +49,10 @@ else()
find_program(PYTHON_EXECUTABLE python3)
if(PYTHON_EXECUTABLE MATCHES "WindowsApps")
# If you hit this error, you will have to install Python 3 or try harder to tell CMake where it is.
message(FATAL_ERROR "Found WindowsApps alias for Python. Make sure Python3 is installed, then choose 'Manage App Execution Aliases' in Start and disable the aliases for Python.")
message(
FATAL_ERROR
"Found WindowsApps alias for Python. Make sure Python3 is installed, then choose 'Manage App Execution Aliases' in Start and disable the aliases for Python."
)
endif()
endif()
@ -56,7 +63,18 @@ find_package(Vulkan MODULE)
find_package(EGL MODULE)
find_package(HIDAPI MODULE)
find_package(OpenHMD MODULE)
find_package(OpenCV COMPONENTS core calib3d highgui imgproc imgcodecs features2d video CONFIG)
find_package(
OpenCV
COMPONENTS
core
calib3d
highgui
imgproc
imgcodecs
features2d
video
CONFIG
)
find_package(Libusb1 MODULE)
find_package(JPEG MODULE)
find_package(realsense2 CONFIG)
@ -94,7 +112,6 @@ if(PKGCONFIG_FOUND AND NOT ANDROID)
pkg_check_modules(FFMPEG libavcodec)
endif()
find_package(OpenGL)
set(OPENGL_WITHOUT_GLX_FOUND ${OPENGL_FOUND})
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
@ -112,23 +129,19 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
pkg_search_module(WAYLAND wayland-client)
pkg_search_module(WAYLAND_SCANNER wayland-scanner)
pkg_search_module(WAYLAND_PROTOCOLS wayland-protocols)
pkg_search_module(LIBDRM libdrm)
pkg_search_module(LIBDRM IMPORTED_TARGET libdrm)
endif()
find_package(OpenGL COMPONENTS GLX)
pkg_search_module(DBUS dbus-1)
pkg_search_module(LIBBSD libbsd)
pkg_check_modules(GST
gstreamer-1.0
gstreamer-app-1.0
gstreamer-video-1.0
)
pkg_check_modules(GST gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0)
pkg_check_modules(SURVIVE IMPORTED_TARGET survive)
else()
endif()
find_library(RT_LIBRARY rt)
if(ANDROID)
find_library(ANDROID_LIBRARY android)
find_library(ANDROID_LOG_LIBRARY log)
@ -149,9 +162,17 @@ foreach(slam_system IN LISTS EXTERNAL_SLAM_SYSTEMS)
endif()
endforeach()
# ILLIXR
set(ILLIXR_PATH
""
CACHE PATH "Path to ILLIXR headers"
)
# This one is named differently because that's what CTest uses
option(BUILD_TESTING "Enable building of the test suite?" ON)
# cmake-format: off
option(XRT_FEATURE_COLOR_LOG "Enable logging in color on supported platforms" ON)
cmake_dependent_option(XRT_HAVE_PERCETTO "Enable percetto support" ON "PERCETTO_FOUND" OFF)
cmake_dependent_option(XRT_FEATURE_TRACING "Enable debug tracing on supported platforms" OFF "XRT_HAVE_PERCETTO" OFF)
@ -198,8 +219,6 @@ endif()
# Most users won't touch these.
mark_as_advanced(XRT_FEATURE_COMPOSITOR_MAIN XRT_FEATURE_OPENXR)
# ILLIXR
set(ILLIXR_PATH "" CACHE PATH "Path to ILLIXR headers")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(XRT_HAVE_LIBUDEV ON)
@ -207,6 +226,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
else()
cmake_dependent_option(XRT_HAVE_LIBUDEV "Enable libudev (used for device probing on Linux)" ON "UDEV_FOUND" OFF)
endif()
cmake_dependent_option(XRT_HAVE_LIBUSB "Enable libusb (used for most drivers)" ON "LIBUSB1_FOUND" OFF)
cmake_dependent_option(XRT_HAVE_JPEG "Enable jpeg code (used for some video drivers)" ON "JPEG_FOUND" OFF)
cmake_dependent_option(XRT_HAVE_OPENCV "Enable OpenCV backend" ON "OpenCV_FOUND" OFF)
@ -248,9 +268,13 @@ cmake_dependent_option(XRT_BUILD_DRIVER_ANDROID "Enable Android sensors driver"
cmake_dependent_option(XRT_BUILD_DRIVER_QWERTY "Enable Qwerty driver" ON "XRT_HAVE_SDL2" OFF)
cmake_dependent_option(XRT_BUILD_DRIVER_EUROC "Enable EuRoC dataset driver for SLAM evaluation" ON "XRT_HAVE_OPENCV" OFF)
# cmake-format: on
# You can set this from a superproject to add a driver
# All drivers must be listed in here to be included in the generated header!
list(APPEND AVAILABLE_DRIVERS
list(
APPEND
AVAILABLE_DRIVERS
"ANDROID"
"ARDUINO"
"DAYDREAM"
@ -276,7 +300,6 @@ list(APPEND AVAILABLE_DRIVERS
"EUROC"
)
# Package name needs to be known by the native code itself.
# Can be overridden from outside/command line
if(ANDROID AND NOT XRT_ANDROID_PACKAGE)
@ -313,7 +336,10 @@ endif()
if(XRT_HAVE_XCB)
set(VK_USE_PLATFORM_XCB_KHR TRUE)
endif()
if(XRT_HAVE_XCB AND XRT_HAVE_XLIB AND XRT_HAVE_XRANDR)
if(XRT_HAVE_XCB
AND XRT_HAVE_XLIB
AND XRT_HAVE_XRANDR
)
set(VK_USE_PLATFORM_XLIB_XRANDR_EXT TRUE)
endif()
if(XRT_HAVE_WAYLAND)
@ -325,19 +351,11 @@ endif()
if(WIN32)
set(VK_USE_PLATFORM_WIN32_KHR TRUE)
endif()
if (XRT_HAVE_VULKAN AND NOT ANDROID)
if(XRT_HAVE_VULKAN AND NOT ANDROID)
set(VK_USE_PLATFORM_DISPLAY_KHR TRUE)
endif()
if(NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra -Wno-unused-parameter")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror-implicit-function-declaration -Werror=incompatible-pointer-types")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=int-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wno-unused-parameter")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
endif()
include(CompilerFlags.cmake)
# Default to PIC code
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@ -348,18 +366,18 @@ if(CMAKE_INTERPROCEDURAL_OPTIMIZATION)
endif()
# Make sure we have pretty colours
option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE)
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE)
if ("${FORCE_COLORED_OUTPUT}")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options (-fdiagnostics-color=always)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options (-fcolor-diagnostics)
endif ()
endif ()
if(FORCE_COLORED_OUTPUT)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()
endif()
###
# Decend into madness.
# Descend into the source
###
add_subdirectory(src)

14
CompilerFlags.cmake Normal file
View file

@ -0,0 +1,14 @@
# Copyright 2018-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
if(NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra -Wno-unused-parameter")
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -Werror-implicit-function-declaration -Werror=incompatible-pointer-types"
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=int-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wno-unused-parameter")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
endif()

View file

@ -3,10 +3,15 @@
# check if Doxygen is installed
find_package(Doxygen)
# cmake-format: off
cmake_dependent_option(BUILD_DOC "Build documentation" ON "DOXYGEN_FOUND" OFF)
cmake_dependent_option(BUILD_DOC_WARN_UNDOCUMENTED "Warn on undocumented entities when building documentation" OFF "DOXYGEN_FOUND" OFF)
cmake_dependent_option(BUILD_DOC_EXTRACT_ALL "Extract all entities for documentation, not just documented ones (conflicts with BUILD_DOC_WARN_UNDOCUMENTED)" ON "DOXYGEN_FOUND AND NOT BUILD_DOC_WARN_UNDOCUMENTED" OFF)
# cmake-format: on
if(BUILD_DOC)
if(BUILD_DOC_WARN_UNDOCUMENTED)
set(DOXYGEN_WARN_UNDOCUMENTED YES)
@ -30,15 +35,18 @@ if(BUILD_DOC)
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
# copy the schema
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/example_configs/config_v0.schema.json
${CMAKE_CURRENT_BINARY_DIR}/html/config_v0.schema.json
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/example_configs/config_v0.schema.json.license
${CMAKE_CURRENT_BINARY_DIR}/html/config_v0.schema.json.license
@ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/example_configs/config_v0.schema.json
${CMAKE_CURRENT_BINARY_DIR}/html/config_v0.schema.json @ONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/example_configs/config_v0.schema.json.license
${CMAKE_CURRENT_BINARY_DIR}/html/config_v0.schema.json.license @ONLY
)
# note the option ALL which allows to build the docs together with the application
add_custom_target(doc_doxygen ALL
add_custom_target(
doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"

View file

@ -5,8 +5,9 @@
add_library(xrt-external-catch2 INTERFACE)
target_include_directories(xrt-external-catch2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/Catch2)
add_library(xrt-external-openvr INTERFACE)
target_include_directories(xrt-external-openvr INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/openvr_includes)
target_include_directories(
xrt-external-openvr INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/openvr_includes
)
# cJSON
add_library(xrt-external-cjson INTERFACE)
@ -31,26 +32,30 @@ target_include_directories(xrt-external-hungarian INTERFACE ${CMAKE_CURRENT_SOUR
# JNIPP and Android JNI wrappers
if(ANDROID)
add_library(xrt-external-jnipp STATIC
jnipp/jnipp.cpp)
add_library(xrt-external-jnipp STATIC jnipp/jnipp.cpp)
target_include_directories(xrt-external-jnipp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/jnipp)
file(GLOB WRAP_SOURCES android-jni-wrap/wrap/*.cpp)
add_library(xrt-external-jni-wrap STATIC
${WRAP_SOURCES})
target_include_directories(xrt-external-jni-wrap PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/android-jni-wrap)
add_library(xrt-external-jni-wrap STATIC ${WRAP_SOURCES})
target_include_directories(
xrt-external-jni-wrap PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/android-jni-wrap
)
target_link_libraries(xrt-external-jni-wrap PUBLIC xrt-external-jnipp)
endif()
# OpenXR
add_library(xrt-external-openxr INTERFACE)
target_include_directories(xrt-external-openxr INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/openxr_includes)
target_include_directories(
xrt-external-openxr INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/openxr_includes
)
# External SLAM tracking
if (SLAM)
if(SLAM)
add_library(xrt-external-slam STATIC slam_tracker/slam_tracker.hpp)
set_target_properties(xrt-external-slam PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(xrt-external-slam INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/slam_tracker)
target_include_directories(
xrt-external-slam INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/slam_tracker
)
target_include_directories(xrt-external-slam INTERFACE ${SLAM_INCLUDE_DIRS})
target_link_libraries(xrt-external-slam INTERFACE ${SLAM_LIBRARIES})
endif()
@ -60,9 +65,7 @@ add_library(xrt-external-stb INTERFACE)
target_include_directories(xrt-external-stb INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/stb)
# imgui
if(XRT_HAVE_SDL2)
# c-imgui doesn't do well with IPO - lots of warnings.
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
if(XRT_HAVE_OPENGL)
add_library(
xrt-external-imgui STATIC
imgui/imgui/cimgui.cpp
@ -88,17 +91,34 @@ if(XRT_HAVE_SDL2)
imgui/imgui/imstb_truetype.h
imgui/imgui_monado/imgui_monado.cpp
)
target_include_directories(xrt-external-imgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
target_compile_definitions(xrt-external-imgui PUBLIC CIMGUI_NO_EXPORT)
target_link_libraries(xrt-external-imgui PRIVATE xrt-external-glad)
add_library(
xrt-external-imgui-sdl2 STATIC imgui/imgui/cimgui_sdl.cpp imgui/imgui/imgui_impl_sdl.cpp
imgui/imgui/imgui_impl_sdl.h
target_include_directories(
xrt-external-imgui SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui
)
target_link_libraries(xrt-external-imgui-sdl2 PRIVATE xrt-external-imgui ${SDL2_LIBRARIES})
target_include_directories(xrt-external-imgui PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
target_compile_definitions(xrt-external-imgui PUBLIC CIMGUI_NO_EXPORT)
set_target_properties(xrt-external-imgui PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
target_link_libraries(xrt-external-imgui PUBLIC xrt-external-glad)
if(XRT_HAVE_SDL2)
add_library(
xrt-external-imgui-sdl2 STATIC
imgui/imgui/cimgui_sdl.cpp imgui/imgui/imgui_impl_sdl.cpp
imgui/imgui/imgui_impl_sdl.h
)
target_link_libraries(
xrt-external-imgui-sdl2
PUBLIC xrt-external-imgui
PRIVATE ${SDL2_LIBRARIES}
)
target_include_directories(xrt-external-imgui-sdl2 PRIVATE ${SDL2_INCLUDE_DIRS})
target_include_directories(
xrt-external-imgui-sdl2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui
)
set_target_properties(
xrt-external-imgui-sdl2 PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF
)
endif()
target_include_directories(xrt-external-imgui-sdl2 PRIVATE ${SDL2_INCLUDE_DIRS})
target_include_directories(xrt-external-imgui-sdl2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
endif()

View file

@ -1,25 +1,37 @@
# Copyright 2019-2020, Collabora, Ltd.
# Copyright 2019-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
add_subdirectory(bindings)
set(ANDROID_SOURCE_FILES
android/android_ahardwarebuffer_allocator.c
android/android_ahardwarebuffer_allocator.h
android/android_custom_surface.cpp
android/android_custom_surface.h
android/android_globals.cpp
android/android_globals.h
android/android_load_class.cpp
android/android_load_class.hpp
android/android_looper.c
android/android_looper.h
android/org.freedesktop.monado.auxiliary.cpp
android/org.freedesktop.monado.auxiliary.hpp
android/org.freedesktop.monado.auxiliary.impl.hpp
# Common includes
add_library(aux-includes INTERFACE)
target_include_directories(
aux-includes INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(aux-includes INTERFACE xrt-interfaces)
set(MATH_SOURCE_FILES
# OpenGL library.
if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES)
add_library(
aux_ogl STATIC
ogl/ogl_documentation.h
ogl/ogl_api.c
ogl/ogl_api.h
ogl/ogl_helpers.c
ogl/ogl_helpers.h
)
target_link_libraries(aux_ogl PUBLIC aux-includes xrt-external-glad)
if(XRT_HAVE_EGL)
target_sources(aux_ogl PRIVATE ogl/egl_api.c ogl/egl_api.h)
endif()
if(XRT_HAVE_OPENGLES)
target_link_libraries(aux_ogl PUBLIC EGL::EGL)
endif()
endif()
# Math library.
add_library(
aux_math STATIC
math/m_api.h
math/m_base.cpp
math/m_eigen_interop.hpp
@ -45,47 +57,43 @@ set(MATH_SOURCE_FILES
math/m_vec2.h
math/m_vec3.h
)
target_link_libraries(aux_math PUBLIC aux-includes aux_util)
target_include_directories(aux_math SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR})
set(OGL_SOURCE_FILES
ogl/ogl_documentation.h
)
if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES)
list(APPEND OGL_SOURCE_FILES
ogl/ogl_api.c
ogl/ogl_api.h
ogl/ogl_helpers.c
ogl/ogl_helpers.h
)
endif()
if(XRT_HAVE_EGL)
list(APPEND OGL_SOURCE_FILES
ogl/egl_api.c
ogl/egl_api.h
)
endif()
set(OS_SOURCE_FILES
# OS library.
add_library(
aux_os STATIC
os/os_ble.h
os/os_documentation.h
os/os_hid.h
os/os_hid_hidraw.c
os/os_threading.h
)
target_link_libraries(aux_os PUBLIC aux-includes xrt-pthreads)
if(XRT_HAVE_DBUS)
list(APPEND OS_SOURCE_FILES
os/os_ble_dbus.c
)
target_sources(aux_os PRIVATE os/os_ble_dbus.c)
target_link_libraries(aux_os PRIVATE ${DBUS_LIBRARIES})
target_include_directories(aux_os SYSTEM PRIVATE ${DBUS_INCLUDE_DIRS})
endif()
set(GSTREAMER_SOURCE_FILES
gstreamer/gst_internal.h
gstreamer/gst_sink.h
gstreamer/gst_sink.c
gstreamer/gst_pipeline.h
gstreamer/gst_pipeline.c
)
# GStreamer library.
if(XRT_HAVE_GST)
add_library(
aux_gstreamer STATIC
gstreamer/gst_internal.h
gstreamer/gst_sink.h
gstreamer/gst_sink.c
gstreamer/gst_pipeline.h
gstreamer/gst_pipeline.c
)
target_link_libraries(aux_gstreamer PUBLIC aux-includes)
target_link_libraries(aux_gstreamer PRIVATE xrt-interfaces aux_math aux_os ${GST_LIBRARIES})
target_include_directories(aux_gstreamer PRIVATE ${GST_INCLUDE_DIRS})
endif()
set(TRACKING_SOURCE_FILES
# Tracking library.
add_library(
aux_tracking STATIC
tracking/t_data_utils.c
tracking/t_imu_fusion.hpp
tracking/t_imu.cpp
@ -94,33 +102,45 @@ set(TRACKING_SOURCE_FILES
tracking/t_lowpass.hpp
tracking/t_tracking.h
)
target_link_libraries(
aux_tracking
PUBLIC aux-includes
PRIVATE aux_math aux_util xrt-external-flexkalman xrt-external-hungarian
)
target_include_directories(aux_tracking SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR})
if(XRT_HAVE_OPENCV)
list(APPEND TRACKING_SOURCE_FILES
tracking/t_calibration_opencv.hpp
tracking/t_calibration.cpp
tracking/t_convert.cpp
tracking/t_debug_hsv_filter.cpp
tracking/t_debug_hsv_picker.cpp
tracking/t_debug_hsv_viewer.cpp
tracking/t_file.cpp
tracking/t_frame_cv_mat_wrapper.cpp
tracking/t_frame_cv_mat_wrapper.hpp
tracking/t_fusion.hpp
tracking/t_helper_debug_sink.hpp
tracking/t_hsv_filter.c
tracking/t_kalman.cpp
tracking/t_tracker_psmv_fusion.hpp
tracking/t_tracker_psmv.cpp
tracking/t_tracker_psvr.cpp
tracking/t_tracker_hand.cpp
target_sources(
aux_tracking
PRIVATE
tracking/t_calibration_opencv.hpp
tracking/t_calibration.cpp
tracking/t_convert.cpp
tracking/t_debug_hsv_filter.cpp
tracking/t_debug_hsv_picker.cpp
tracking/t_debug_hsv_viewer.cpp
tracking/t_file.cpp
tracking/t_frame_cv_mat_wrapper.cpp
tracking/t_frame_cv_mat_wrapper.hpp
tracking/t_fusion.hpp
tracking/t_helper_debug_sink.hpp
tracking/t_hsv_filter.c
tracking/t_kalman.cpp
tracking/t_tracker_psmv_fusion.hpp
tracking/t_tracker_psmv.cpp
tracking/t_tracker_psvr.cpp
tracking/t_tracker_hand.cpp
)
target_include_directories(aux_tracking SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(aux_tracking PUBLIC ${OpenCV_LIBRARIES})
endif()
if(XRT_HAVE_SLAM)
list(APPEND TRACKING_SOURCE_FILES tracking/t_tracker_slam.cpp)
target_sources(aux_tracking PRIVATE tracking/t_tracker_slam.cpp)
target_link_libraries(aux_tracking PRIVATE xrt-external-slam)
endif()
set(UTIL_SOURCE_FILES
# Util library.
add_library(
aux_util STATIC
util/u_bitwise.c
util/u_bitwise.h
util/u_debug.c
@ -178,75 +198,24 @@ set(UTIL_SOURCE_FILES
util/u_verify.h
util/u_process.c
util/u_process.h
"${CMAKE_CURRENT_BINARY_DIR}/u_git_tag.c"
)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/util/u_git_tag.c.in" "${CMAKE_CURRENT_BINARY_DIR}/u_git_tag.c" @ONLY)
list(APPEND UTIL_SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/u_git_tag.c")
set(VK_SOURCE_FILES
vk/vk_command_buffer.c
vk/vk_documentation.h
vk/vk_helpers.c
vk/vk_helpers.h
vk/vk_image_allocator.c
vk/vk_image_allocator.h
vk/vk_state_creators.c
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/util/u_git_tag.c.in" "${CMAKE_CURRENT_BINARY_DIR}/u_git_tag.c"
@ONLY
)
# Common includes
add_library(aux-includes INTERFACE)
target_include_directories(aux-includes INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(aux-includes INTERFACE xrt-interfaces)
if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES)
# OpenGL library.
add_library(aux_ogl STATIC ${OGL_SOURCE_FILES})
target_link_libraries(aux_ogl PUBLIC aux-includes)
# for GLAD
target_link_libraries(aux_ogl PUBLIC xrt-external-glad)
if(XRT_HAVE_OPENGLES)
target_link_libraries(aux_ogl PUBLIC EGL::EGL)
endif()
endif()
# OS library.
add_library(aux_os STATIC ${OS_SOURCE_FILES})
target_link_libraries(aux_os PUBLIC aux-includes xrt-pthreads)
if(XRT_HAVE_DBUS)
target_link_libraries(aux_os PRIVATE ${DBUS_LIBRARIES})
target_include_directories(aux_os SYSTEM
PRIVATE
${DBUS_INCLUDE_DIRS}
)
endif()
# Math library.
add_library(aux_math STATIC ${MATH_SOURCE_FILES})
target_link_libraries(aux_math PUBLIC aux-includes aux_util)
# Math files has extra include(s).
target_include_directories(aux_math SYSTEM
PRIVATE ${EIGEN3_INCLUDE_DIR}
)
# Util library.
add_library(aux_util STATIC ${UTIL_SOURCE_FILES})
target_link_libraries(aux_util PUBLIC aux-includes xrt-pthreads aux_generated_bindings)
# for u_device
target_link_libraries(aux_util PUBLIC aux_math)
target_link_libraries(aux_util PUBLIC aux-includes xrt-pthreads aux_generated_bindings aux_math)
if(XRT_HAVE_JPEG)
target_link_libraries(aux_util PRIVATE ${JPEG_LIBRARIES})
target_include_directories(aux_util PRIVATE ${JPEG_INCLUDE_DIRS})
endif()
# for cJSON
if(XRT_HAVE_SYSTEM_CJSON)
target_link_libraries(aux_util PUBLIC cJSON::cJSON)
target_compile_definitions(aux_util PRIVATE XRT_HAVE_SYSTEM_CJSON)
else()
target_link_libraries(aux_util PUBLIC xrt-external-cjson)
endif()
# For u_trace_marker
if(XRT_FEATURE_TRACING AND XRT_HAVE_PERCETTO)
target_link_libraries(aux_util PUBLIC Percetto::percetto)
endif()
@ -258,62 +227,18 @@ if(ANDROID)
target_link_libraries(aux_util PUBLIC ${ANDROID_LOG_LIBRARY})
endif()
# GStreamer library.
if(XRT_HAVE_GST)
add_library(aux_gstreamer STATIC ${GSTREAMER_SOURCE_FILES})
target_link_libraries(aux_gstreamer PUBLIC
aux-includes
)
target_link_libraries(aux_gstreamer PRIVATE
xrt-interfaces
aux_math
aux_os
${GST_LIBRARIES}
)
target_include_directories(aux_gstreamer PRIVATE
${GST_INCLUDE_DIRS}
)
endif()
# Tracking library.
add_library(aux_tracking STATIC ${TRACKING_SOURCE_FILES})
target_link_libraries(aux_tracking PUBLIC aux-includes PRIVATE aux_math aux_util)
# Tracking files have extra includes.
target_include_directories(aux_tracking SYSTEM
PRIVATE
${EIGEN3_INCLUDE_DIR}
)
target_link_libraries(aux_tracking PRIVATE
xrt-external-flexkalman
xrt-external-hungarian
)
if(XRT_HAVE_OPENCV)
target_include_directories(aux_tracking SYSTEM
PRIVATE
${OpenCV_INCLUDE_DIRS}
)
target_link_libraries(aux_tracking PUBLIC ${OpenCV_LIBRARIES})
if(XRT_HAVE_SLAM)
target_link_libraries(aux_tracking PRIVATE xrt-external-slam)
endif()
endif()
if (XRT_BUILD_DRIVER_VIVE OR XRT_BUILD_DRIVER_SURVIVE)
set(VIVE_CONFIG_SOURCE_FILES
vive/vive_config.h
vive/vive_config.c
)
add_library(aux_vive STATIC ${VIVE_CONFIG_SOURCE_FILES})
target_link_libraries(aux_vive PRIVATE xrt-interfaces aux_util aux_math aux_tracking xrt-external-cjson)
target_link_libraries(aux_vive PRIVATE ${ZLIB_LIBRARIES})
target_include_directories(aux_vive PRIVATE ${ZLIB_INCLUDE_DIRS})
endif()
if(XRT_HAVE_VULKAN)
# Vulkan library.
add_library(aux_vk STATIC ${VK_SOURCE_FILES})
add_library(
aux_vk STATIC
vk/vk_command_buffer.c
vk/vk_documentation.h
vk/vk_helpers.c
vk/vk_helpers.h
vk/vk_image_allocator.c
vk/vk_image_allocator.h
vk/vk_state_creators.c
)
target_link_libraries(aux_vk PUBLIC aux_os aux_util)
target_link_libraries(aux_vk PUBLIC Vulkan::Vulkan)
target_include_directories(aux_vk PUBLIC ${Vulkan_INCLUDE_DIR})
@ -322,15 +247,58 @@ if(XRT_HAVE_VULKAN)
endif()
endif()
if(XRT_BUILD_DRIVER_VIVE OR XRT_BUILD_DRIVER_SURVIVE)
set(VIVE_CONFIG_SOURCE_FILES vive/vive_config.h vive/vive_config.c)
add_library(aux_vive STATIC ${VIVE_CONFIG_SOURCE_FILES})
target_link_libraries(
aux_vive
PRIVATE
xrt-interfaces
aux_util
aux_math
aux_tracking
xrt-external-cjson
${ZLIB_LIBRARIES}
)
target_include_directories(aux_vive PRIVATE ${ZLIB_INCLUDE_DIRS})
endif()
if(ANDROID)
add_library(android_app_glue STATIC
${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
target_include_directories(android_app_glue PUBLIC ${ANDROID_NDK}/sources/android/native_app_glue)
add_library(aux_android STATIC ${ANDROID_SOURCE_FILES})
target_link_libraries(aux_android
add_library(
android_app_glue STATIC
${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c
)
target_include_directories(
android_app_glue PUBLIC ${ANDROID_NDK}/sources/android/native_app_glue
)
# disable these warnings in external code
target_compile_options(android_app_glue PRIVATE -Wno-format-pedantic)
add_library(
aux_android STATIC
android/android_ahardwarebuffer_allocator.c
android/android_ahardwarebuffer_allocator.h
android/android_custom_surface.cpp
android/android_custom_surface.h
android/android_globals.cpp
android/android_globals.h
android/android_load_class.cpp
android/android_load_class.hpp
android/android_looper.c
android/android_looper.h
android/org.freedesktop.monado.auxiliary.cpp
android/org.freedesktop.monado.auxiliary.hpp
android/org.freedesktop.monado.auxiliary.impl.hpp
)
target_link_libraries(
aux_android
PUBLIC aux_util
PRIVATE ${ANDROID_LIBRARY} ${ANDROID_LOG_LIBRARY} xrt-external-jni-wrap xrt-external-jnipp android_app_glue
PRIVATE
${ANDROID_LIBRARY}
${ANDROID_LOG_LIBRARY}
xrt-external-jni-wrap
xrt-external-jnipp
android_app_glue
)
target_link_libraries(aux_vk PUBLIC aux_android)
endif()

View file

@ -1,30 +1,31 @@
# Copyright 2019-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
###
# Binding generation
#
function(bindings_gen output custom_target)
add_custom_command(OUTPUT ${output}
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/bindings.py
# Binding generation: pass filename to generate
function(bindings_gen output)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${output}"
COMMAND
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/bindings.py
${CMAKE_CURRENT_SOURCE_DIR}/bindings.json
${output}
"${CMAKE_CURRENT_BINARY_DIR}/${output}"
VERBATIM
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bindings.py
${CMAKE_CURRENT_SOURCE_DIR}/bindings.json
)
add_custom_target(${custom_target} DEPENDS ${output})
endfunction(bindings_gen)
COMMENT "Generating ${output}"
)
endfunction()
bindings_gen(${CMAKE_CURRENT_BINARY_DIR}/b_generated_bindings.h generated_bindings_h)
bindings_gen(${CMAKE_CURRENT_BINARY_DIR}/b_generated_bindings.c generated_bindings_c)
bindings_gen(b_generated_bindings.h)
bindings_gen(b_generated_bindings.c)
# Bindings library.
add_library(aux_generated_bindings STATIC ${CMAKE_CURRENT_BINARY_DIR}/b_generated_bindings.c)
add_dependencies(aux_generated_bindings generated_bindings_h)
add_library(
aux_generated_bindings STATIC ${CMAKE_CURRENT_BINARY_DIR}/b_generated_bindings.c
${CMAKE_CURRENT_BINARY_DIR}/b_generated_bindings.h
)
# needed globally for steamvr input profile generation in steamvr target
set_property(GLOBAL PROPERTY AUX_BINDINGS_DIR_PROP "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(aux_generated_bindings PRIVATE aux-includes xrt-interfaces)
target_link_libraries(aux_generated_bindings PRIVATE xrt-interfaces aux_util)

View file

@ -1,289 +1,264 @@
# Copyright 2019-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
spirv_shaders(SHADER_HEADERS
shaders/clear.comp
shaders/distortion.comp
shaders/distortion_timewarp.comp
shaders/mesh.frag
shaders/mesh.vert
shaders/layer.frag
shaders/layer.vert
shaders/equirect1.vert
shaders/equirect1.frag
shaders/equirect2.vert
shaders/equirect2.frag
)
set(CLIENT_SOURCE_FILES)
set(UTIL_SOURCE_FILES
util/comp_base.h
util/comp_base.c
util/comp_swapchain.h
util/comp_swapchain.c
util/comp_sync.h
util/comp_sync.c
util/comp_vulkan.h
util/comp_vulkan.c
)
set(RENDER_SOURCE_FILES
render/comp_buffer.c
render/comp_compute.c
render/comp_render.h
render/comp_rendering.c
render/comp_resources.c
render/comp_shaders.c
render/comp_util.c
)
set(MAIN_SOURCE_FILES
main/comp_compositor.c
main/comp_compositor.h
main/comp_documentation.h
main/comp_renderer.c
main/comp_renderer.h
main/comp_settings.c
main/comp_settings.h
main/comp_target.h
main/comp_target_swapchain.c
main/comp_target_swapchain.h
main/comp_window.h
main/comp_layer.h
main/comp_layer.c
main/comp_layer_renderer.h
main/comp_layer_renderer.c
)
set(MULTI_SOURCE_FILES
multi/comp_multi_compositor.c
multi/comp_multi_interface.h
multi/comp_multi_private.h
multi/comp_multi_system.c
)
###
# Client library
#
if(XRT_HAVE_VULKAN)
list(APPEND CLIENT_SOURCE_FILES
client/comp_vk_client.c
client/comp_vk_client.h
client/comp_vk_glue.c
)
endif()
if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES)
list(APPEND CLIENT_SOURCE_FILES
client/comp_gl_client.c
client/comp_gl_client.h
client/comp_gl_memobj_swapchain.c
client/comp_gl_memobj_swapchain.h
)
endif()
if(XRT_HAVE_OPENGL)
list(APPEND CLIENT_SOURCE_FILES
client/comp_gl_glue.c
)
endif()
if(XRT_HAVE_OPENGLES)
list(APPEND CLIENT_SOURCE_FILES
client/comp_gles_glue.c
client/comp_gl_eglimage_swapchain.c
client/comp_gl_eglimage_swapchain.h
)
endif()
if(XRT_HAVE_OPENGL_GLX AND XRT_HAVE_XLIB)
list(APPEND CLIENT_SOURCE_FILES
client/comp_gl_xlib_client.c
client/comp_gl_xlib_client.h
client/comp_gl_xlib_glue.c
)
endif()
if(XRT_HAVE_EGL)
list(APPEND CLIENT_SOURCE_FILES
client/comp_egl_client.c
client/comp_egl_client.h
)
endif()
add_library(comp_client STATIC)
add_library(comp_client STATIC ${CLIENT_SOURCE_FILES})
target_link_libraries(comp_client PUBLIC xrt-interfaces PRIVATE aux_util)
target_link_libraries(
comp_client
PUBLIC xrt-interfaces
PRIVATE aux_util
)
target_include_directories(comp_client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
if(XRT_HAVE_VULKAN)
target_sources(
comp_client PRIVATE client/comp_vk_client.c client/comp_vk_client.h
client/comp_vk_glue.c
)
target_link_libraries(comp_client PRIVATE aux_vk)
endif()
if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES)
target_sources(
comp_client
PRIVATE client/comp_gl_client.c client/comp_gl_client.h
client/comp_gl_memobj_swapchain.c client/comp_gl_memobj_swapchain.h
)
target_link_libraries(comp_client PRIVATE aux_ogl)
endif()
if(XRT_HAVE_OPENGL AND XRT_HAVE_XLIB)
if(XRT_HAVE_OPENGL)
target_sources(comp_client PRIVATE client/comp_gl_glue.c)
endif()
if(XRT_HAVE_OPENGLES)
target_sources(
comp_client PRIVATE client/comp_gles_glue.c client/comp_gl_eglimage_swapchain.c
client/comp_gl_eglimage_swapchain.h
)
endif()
if(XRT_HAVE_OPENGL_GLX AND XRT_HAVE_XLIB)
target_sources(
comp_client PRIVATE client/comp_gl_xlib_client.c client/comp_gl_xlib_client.h
client/comp_gl_xlib_glue.c
)
target_link_libraries(comp_client PRIVATE OpenGL::GLX)
endif()
if(XRT_HAVE_EGL)
target_sources(comp_client PRIVATE client/comp_egl_client.c client/comp_egl_client.h)
endif()
##
# Util library
#
if(XRT_HAVE_VULKAN)
add_library(comp_util STATIC ${UTIL_SOURCE_FILES})
target_link_libraries(comp_util PUBLIC xrt-interfaces PRIVATE aux_util aux_os aux_vk)
add_library(
comp_util STATIC
util/comp_base.h
util/comp_base.c
util/comp_swapchain.h
util/comp_swapchain.c
util/comp_sync.h
util/comp_sync.c
util/comp_vulkan.h
util/comp_vulkan.c
)
target_link_libraries(
comp_util
PUBLIC xrt-interfaces
PRIVATE aux_util aux_os aux_vk
)
target_include_directories(comp_util PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
endif()
##
# Render library
#
if(XRT_HAVE_VULKAN)
add_library(comp_render STATIC ${SHADER_HEADERS} ${RENDER_SOURCE_FILES})
target_link_libraries(comp_render PUBLIC xrt-interfaces PRIVATE aux_util aux_os aux_vk)
target_include_directories(comp_render PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(comp_render SYSTEM PRIVATE
# Shaders - marked SYSTEM so we get no warnings
${CMAKE_CURRENT_BINARY_DIR}
spirv_shaders(
SHADER_HEADERS
shaders/clear.comp
shaders/distortion.comp
shaders/distortion_timewarp.comp
shaders/mesh.frag
shaders/mesh.vert
shaders/layer.frag
shaders/layer.vert
shaders/equirect1.vert
shaders/equirect1.frag
shaders/equirect2.vert
shaders/equirect2.frag
)
add_library(
comp_render STATIC
${SHADER_HEADERS}
render/comp_buffer.c
render/comp_compute.c
render/comp_render.h
render/comp_rendering.c
render/comp_resources.c
render/comp_shaders.c
render/comp_util.c
)
target_link_libraries(
comp_render
PUBLIC xrt-interfaces
PRIVATE aux_util aux_os aux_vk
)
target_include_directories(comp_render PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
# Shaders - marked SYSTEM so we get no warnings
target_include_directories(comp_render SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(shaders)
endif()
##
# Main library
#
if(XRT_FEATURE_COMPOSITOR_MAIN)
add_library(
comp_main STATIC
main/comp_compositor.c
main/comp_compositor.h
main/comp_documentation.h
main/comp_renderer.c
main/comp_renderer.h
main/comp_settings.c
main/comp_settings.h
main/comp_target.h
main/comp_target_swapchain.c
main/comp_target_swapchain.h
main/comp_window.h
main/comp_layer.h
main/comp_layer.c
main/comp_layer_renderer.h
main/comp_layer_renderer.c
)
target_link_libraries(
comp_main
PUBLIC xrt-interfaces
PRIVATE
aux_util
aux_os
aux_vk
comp_util
comp_render
)
target_include_directories(comp_main PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
if(XRT_HAVE_XCB)
list(APPEND MAIN_SOURCE_FILES
main/comp_window_xcb.c
)
target_sources(comp_main PRIVATE main/comp_window_xcb.c)
target_include_directories(comp_main SYSTEM PRIVATE ${XCB_INCLUDE_DIRS})
target_link_libraries(comp_main PRIVATE ${XCB_LIBRARIES})
if(XRT_HAVE_EGL)
target_include_directories(comp_main SYSTEM PRIVATE ${EGL_INCLUDE_DIRS})
target_link_libraries(comp_main PRIVATE ${XCB_LIBRARIES})
endif()
endif()
if(XRT_HAVE_XCB AND XRT_HAVE_XLIB)
list(APPEND MAIN_SOURCE_FILES
main/comp_window_direct_randr.c
main/comp_window_direct_nvidia.c
target_sources(
comp_main PRIVATE main/comp_window_direct_randr.c
main/comp_window_direct_nvidia.c
)
target_link_libraries(comp_main PRIVATE ${X11_X11_LIB})
endif()
if(WIN32)
list(APPEND MAIN_SOURCE_FILES
main/comp_window_mswin.c
)
target_sources(comp_main PRIVATE main/comp_window_mswin.c)
endif()
if (VK_USE_PLATFORM_DISPLAY_KHR)
list(APPEND MAIN_SOURCE_FILES
main/comp_window_vk_display.c
)
if(VK_USE_PLATFORM_DISPLAY_KHR)
target_sources(comp_main PRIVATE main/comp_window_vk_display.c)
endif()
if (VK_USE_PLATFORM_DISPLAY_KHR OR XRT_HAVE_XCB)
list(APPEND MAIN_SOURCE_FILES
main/comp_window_direct.c
)
if(VK_USE_PLATFORM_DISPLAY_KHR OR XRT_HAVE_XCB)
target_sources(comp_main PRIVATE main/comp_window_direct.c)
endif()
# generate wayland protocols
if(XRT_HAVE_WAYLAND)
target_sources(comp_main PRIVATE main/comp_window_wayland.c)
pkg_get_variable(WL_PROTOS_PKG_DIR wayland-protocols pkgdatadir)
pkg_get_variable(WL_SCANNER wayland-scanner wayland_scanner)
set(WL_PROTOS_DIR "${CMAKE_CURRENT_BINARY_DIR}/wayland-protocols")
file(MAKE_DIRECTORY "${WL_PROTOS_DIR}")
set(WL_PROTOS_XML
${WL_PROTOS_PKG_DIR}/stable/xdg-shell/xdg-shell.xml
)
set(WL_PROTOS_XML ${WL_PROTOS_PKG_DIR}/stable/xdg-shell/xdg-shell.xml)
list(APPEND MAIN_SOURCE_FILES
main/comp_window_wayland.c
)
target_include_directories(comp_main SYSTEM PRIVATE ${WL_PROTOS_DIR})
target_link_libraries(comp_main PRIVATE ${WAYLAND_LIBRARIES})
if (XRT_HAVE_WAYLAND_DIRECT)
list(APPEND WL_PROTOS_XML
if(XRT_HAVE_WAYLAND_DIRECT)
list(
APPEND WL_PROTOS_XML
${WL_PROTOS_PKG_DIR}/staging/drm-lease/drm-lease-v1.xml
)
list(APPEND MAIN_SOURCE_FILES
main/comp_window_direct_wayland.c
)
pkg_check_modules(LIBDRM IMPORTED_TARGET libdrm)
set(WAYLAND_DEPS
${WAYLAND_LIBRARIES}
PkgConfig::LIBDRM
)
target_sources(comp_main PRIVATE main/comp_window_direct_wayland.c)
target_link_libraries(comp_main PRIVATE PkgConfig::LIBDRM)
endif()
foreach(WL_PROTO_XML ${WL_PROTOS_XML})
get_filename_component(WL_PROTO ${WL_PROTO_XML} NAME_WE)
foreach(wl_proto_xml ${WL_PROTOS_XML})
get_filename_component(WL_PROTO ${wl_proto_xml} NAME_WE)
set(WL_PROTO_C "${WL_PROTOS_DIR}/${WL_PROTO}.c")
set(WL_PROTO_H "${WL_PROTOS_DIR}/${WL_PROTO}-client-protocol.h")
add_custom_command(
OUTPUT "${WL_PROTO_C}"
COMMAND
${WL_SCANNER} private-code "${WL_PROTO_XML}" "${WL_PROTO_C}"
OUTPUT "${WL_PROTO_C}" VERBATIM)
"${WL_SCANNER}" private-code "${wl_proto_xml}"
"${WL_PROTO_C}"
VERBATIM
DEPENDS "${WL_SCANNER}" "${wl_proto_xml}"
COMMENT "Generating ${WL_PROTO_C}"
)
add_custom_command(
OUTPUT "${WL_PROTO_H}"
COMMAND
${WL_SCANNER} client-header "${WL_PROTO_XML}" "${WL_PROTO_H}"
OUTPUT "${WL_PROTO_H}" VERBATIM)
list(APPEND MAIN_SOURCE_FILES
${WL_PROTO_C}
${WL_PROTO_H}
"${WL_SCANNER}" client-header "${wl_proto_xml}"
"${WL_PROTO_H}"
VERBATIM
DEPENDS "${WL_SCANNER}" "${wl_proto_xml}"
COMMENT "Generating ${WL_PROTO_H}"
)
target_sources(comp_main PRIVATE ${WL_PROTO_C} ${WL_PROTO_H})
endforeach()
endif()
if(ANDROID)
list(APPEND MAIN_SOURCE_FILES
main/comp_window_android.c
)
endif()
add_library(comp_main STATIC ${MAIN_SOURCE_FILES})
target_link_libraries(comp_main PUBLIC xrt-interfaces PRIVATE aux_util aux_os aux_vk comp_util comp_render)
target_include_directories(comp_main PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
if(XRT_HAVE_WAYLAND)
target_include_directories(comp_main SYSTEM PRIVATE ${WL_PROTOS_DIR})
target_link_libraries(comp_main PRIVATE
${WAYLAND_DEPS} ${WAYLAND_LIBRARIES}
)
endif()
if(XRT_HAVE_XCB)
target_include_directories(comp_main SYSTEM PRIVATE ${XCB_INCLUDE_DIRS})
target_link_libraries(comp_main PRIVATE ${XCB_LIBRARIES})
endif()
if(XRT_HAVE_XCB AND XRT_HAVE_XLIB)
target_link_libraries(comp_main PRIVATE ${X11_X11_LIB})
endif()
if(XRT_HAVE_EGL AND XRT_HAVE_XCB)
target_include_directories(comp_main SYSTEM PRIVATE ${EGL_INCLUDE_DIRS})
target_link_libraries(comp_main PRIVATE ${XCB_LIBRARIES})
endif()
if(ANDROID)
target_sources(comp_main PRIVATE main/comp_window_android.c)
target_link_libraries(comp_main PRIVATE aux_ogl aux_android)
endif()
endif()
###
# Multi client compositor library
#
add_library(comp_multi STATIC ${MULTI_SOURCE_FILES})
target_link_libraries(comp_multi PUBLIC xrt-interfaces PRIVATE aux_util aux_os)
add_library(
comp_multi STATIC multi/comp_multi_compositor.c multi/comp_multi_interface.h
multi/comp_multi_private.h multi/comp_multi_system.c
)
target_link_libraries(
comp_multi
PUBLIC xrt-interfaces
PRIVATE aux_util aux_os
)
target_include_directories(comp_multi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if(XRT_FEATURE_COMPOSITOR_MAIN)
target_link_libraries(comp_main PRIVATE comp_multi)
endif()

View file

@ -2,69 +2,63 @@
#
# SPDX-License-Identifier: BSL-1.0
set(ENABLED_HEADSET_DRIVERS)
set(ENABLED_DRIVERS)
add_library(drv_includes INTERFACE)
target_include_directories(drv_includes INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
if(XRT_BUILD_DRIVER_ARDUINO)
add_library(drv_arduino STATIC
arduino/arduino_device.c
arduino/arduino_interface.h
arduino/arduino_prober.c)
add_library(
drv_arduino STATIC arduino/arduino_device.c arduino/arduino_interface.h
arduino/arduino_prober.c
)
target_link_libraries(drv_arduino PRIVATE xrt-interfaces aux_util aux_os)
list(APPEND ENABLED_DRIVERS arduino)
endif()
if(XRT_BUILD_DRIVER_DAYDREAM)
add_library(drv_daydream STATIC
daydream/daydream_device.c
daydream/daydream_device.h
daydream/daydream_interface.h
daydream/daydream_prober.c)
add_library(
drv_daydream STATIC daydream/daydream_device.c daydream/daydream_device.h
daydream/daydream_interface.h daydream/daydream_prober.c
)
target_link_libraries(drv_daydream PRIVATE xrt-interfaces aux_util aux_os)
list(APPEND ENABLED_DRIVERS daydream)
endif()
if(XRT_BUILD_DRIVER_DEPTHAI)
add_library(drv_depthai STATIC
depthai/depthai_driver.cpp
depthai/depthai_interface.h)
target_link_libraries(drv_depthai PRIVATE
xrt-interfaces
aux_os
${OpenCV_LIBRARIES}
depthai::opencv
depthai::core
XLink
add_library(drv_depthai STATIC depthai/depthai_driver.cpp depthai/depthai_interface.h)
target_link_libraries(
drv_depthai
PRIVATE
xrt-interfaces
aux_os
${OpenCV_LIBRARIES}
depthai::opencv
depthai::core
XLink
)
target_include_directories(drv_depthai PRIVATE ${OpenCV_INCLUDE_DIRS})
list(APPEND ENABLED_DRIVERS depthai)
endif()
if(XRT_BUILD_DRIVER_DUMMY)
add_library(drv_dummy STATIC
dummy/dummy_hmd.c
dummy/dummy_interface.h
dummy/dummy_prober.c)
add_library(drv_dummy STATIC dummy/dummy_hmd.c dummy/dummy_interface.h dummy/dummy_prober.c)
target_link_libraries(drv_dummy PRIVATE xrt-interfaces aux_util)
list(APPEND ENABLED_HEADSET_DRIVERS dummy)
endif()
if(XRT_BUILD_DRIVER_QWERTY)
add_library(drv_qwerty STATIC
add_library(
drv_qwerty STATIC
qwerty/qwerty_device.c
qwerty/qwerty_device.h
qwerty/qwerty_interface.h
qwerty/qwerty_prober.c
qwerty/qwerty_sdl.c)
target_link_libraries(drv_qwerty PRIVATE
xrt-interfaces
aux_util
${SDL2_LIBRARIES}
)
target_include_directories(drv_qwerty PRIVATE
${SDL2_INCLUDE_DIRS}
qwerty/qwerty_sdl.c
)
target_link_libraries(drv_qwerty PRIVATE xrt-interfaces aux_util ${SDL2_LIBRARIES})
target_include_directories(drv_qwerty PRIVATE ${SDL2_INCLUDE_DIRS})
list(APPEND ENABLED_DRIVERS qwerty)
add_library(drv_qwerty_includes INTERFACE)
@ -72,107 +66,107 @@ if(XRT_BUILD_DRIVER_QWERTY)
endif()
if(XRT_BUILD_DRIVER_HDK)
set(HDK_SOURCE_FILES
)
set(HDK_SOURCE_FILES)
add_library(drv_hdk STATIC
hdk/hdk_device.cpp
hdk/hdk_device.h
hdk/hdk_interface.h
hdk/hdk_prober.c)
add_library(
drv_hdk STATIC hdk/hdk_device.cpp hdk/hdk_device.h hdk/hdk_interface.h
hdk/hdk_prober.c
)
target_link_libraries(drv_hdk PRIVATE xrt-interfaces aux_math)
list(APPEND ENABLED_HEADSET_DRIVERS hdk)
endif()
if(XRT_BUILD_DRIVER_HYDRA)
set(HYDRA_SOURCE_FILES
)
set(HYDRA_SOURCE_FILES)
add_library(drv_hydra STATIC
hydra/hydra_driver.c
hydra/hydra_interface.h)
add_library(drv_hydra STATIC hydra/hydra_driver.c hydra/hydra_interface.h)
target_link_libraries(drv_hydra PRIVATE xrt-interfaces aux_os)
list(APPEND ENABLED_DRIVERS hydra)
endif()
if(XRT_BUILD_DRIVER_NS)
add_library(drv_ns STATIC
add_library(
drv_ns STATIC
north_star/distortion_3d/utility_northstar.h
north_star/distortion_3d/deformation_northstar.h
north_star/distortion_3d/deformation_northstar.cpp
north_star/ns_hmd.h
north_star/ns_hmd.c
north_star/ns_interface.h
north_star/ns_prober.c)
north_star/ns_prober.c
)
target_link_libraries(drv_ns PRIVATE xrt-interfaces aux_math xrt-external-cjson)
list(APPEND ENABLED_HEADSET_DRIVERS ns)
endif()
if(XRT_BUILD_DRIVER_ULV2)
add_library(drv_ulv2 STATIC
ultraleap_v2/ulv2_driver.cpp
ultraleap_v2/ulv2_interface.h)
add_library(drv_ulv2 STATIC ultraleap_v2/ulv2_driver.cpp ultraleap_v2/ulv2_interface.h)
target_link_libraries(drv_ulv2 PRIVATE xrt-interfaces aux_util aux_math LeapV2::LeapV2)
endif()
if(XRT_BUILD_DRIVER_OHMD)
add_library(drv_ohmd STATIC
ohmd/oh_device.c
ohmd/oh_device.h
ohmd/oh_interface.h
ohmd/oh_prober.c)
add_library(
drv_ohmd STATIC ohmd/oh_device.c ohmd/oh_device.h ohmd/oh_interface.h
ohmd/oh_prober.c
)
target_link_libraries(drv_ohmd PRIVATE xrt-interfaces OpenHMD::OpenHMD aux_util aux_math)
list(APPEND ENABLED_HEADSET_DRIVERS openhmd)
endif()
if(XRT_BUILD_DRIVER_PSMV)
add_library(drv_psmv STATIC
psmv/psmv_driver.c
psmv/psmv_interface.h)
target_link_libraries(drv_psmv PRIVATE xrt-interfaces PUBLIC aux_os aux_tracking)
add_library(drv_psmv STATIC psmv/psmv_driver.c psmv/psmv_interface.h)
target_link_libraries(
drv_psmv
PRIVATE xrt-interfaces
PUBLIC aux_os aux_tracking
)
list(APPEND ENABLED_DRIVERS psmv)
endif()
if(XRT_BUILD_DRIVER_PSVR)
add_library(drv_psvr STATIC
add_library(
drv_psvr STATIC
psvr/psvr_device.c
psvr/psvr_device.h
psvr/psvr_interface.h
psvr/psvr_packet.c
psvr/psvr_prober.c)
psvr/psvr_prober.c
)
target_link_libraries(drv_psvr PRIVATE xrt-interfaces HIDAPI::hidapi aux_util)
target_include_directories(drv_psvr PRIVATE ${HIDAPI_INCLUDE_DIRS})
list(APPEND ENABLED_HEADSET_DRIVERS psvr)
endif()
if(XRT_BUILD_DRIVER_RS)
add_library(drv_rs STATIC
add_library(
drv_rs STATIC
realsense/rs_ddev.c
realsense/rs_hdev.c
realsense/rs_prober.c
realsense/rs_driver.h
realsense/rs_interface.h)
realsense/rs_interface.h
)
target_link_libraries(drv_rs PRIVATE xrt-interfaces realsense2::realsense2 aux_util)
list(APPEND ENABLED_HEADSET_DRIVERS rs)
endif()
if(XRT_BUILD_DRIVER_REMOTE)
add_library(drv_remote STATIC
add_library(
drv_remote STATIC
remote/r_device.c
remote/r_hmd.c
remote/r_hub.c
remote/r_interface.h
remote/r_internal.h)
remote/r_internal.h
)
target_link_libraries(drv_remote PRIVATE xrt-interfaces aux_util)
list(APPEND ENABLED_HEADSET_DRIVERS remote)
endif()
set(VIVE_CONFIG_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/vive")
if(XRT_BUILD_DRIVER_VIVE)
add_library(drv_vive STATIC
add_library(
drv_vive STATIC
vive/vive_device.h
vive/vive_device.c
vive/vive_prober.h
@ -182,24 +176,30 @@ if(XRT_BUILD_DRIVER_VIVE)
vive/vive_controller.h
vive/vive_controller.c
vive/vive_lighthouse.h
vive/vive_lighthouse.c)
target_link_libraries(drv_vive PRIVATE xrt-interfaces aux_os aux_util aux_math xrt-external-cjson aux_vive)
vive/vive_lighthouse.c
)
target_link_libraries(
drv_vive
PRIVATE
xrt-interfaces
aux_os
aux_util
aux_math
xrt-external-cjson
aux_vive
)
target_link_libraries(drv_vive PRIVATE ${ZLIB_LIBRARIES})
target_include_directories(drv_vive PRIVATE ${ZLIB_INCLUDE_DIRS})
list(APPEND ENABLED_HEADSET_DRIVERS vive)
if (XRT_BUILD_DRIVER_HANDTRACKING)
if(XRT_BUILD_DRIVER_HANDTRACKING)
target_link_libraries(drv_vive PRIVATE drv_ht)
endif()
endif()
if(XRT_HAVE_V4L2)
add_library(drv_v4l2 STATIC v4l2/v4l2_driver.c)
target_link_libraries(drv_v4l2 PRIVATE
xrt-interfaces
aux_os
aux_util
)
target_link_libraries(drv_v4l2 PRIVATE xrt-interfaces aux_os aux_util)
list(APPEND ENABLED_DRIVERS v4l2)
endif()
@ -211,7 +211,8 @@ if(XRT_BUILD_DRIVER_VF)
endif()
if(XRT_BUILD_DRIVER_HANDTRACKING)
add_library(drv_ht STATIC
add_library(
drv_ht STATIC
ht/ht_algorithm.cpp
ht/ht_driver.cpp
ht/ht_driver.hpp
@ -219,56 +220,83 @@ if(XRT_BUILD_DRIVER_HANDTRACKING)
ht/ht_models.cpp
ht/ht_hand_math.cpp
ht/ht_image_math.cpp
ht/ht_nms.cpp)
target_link_libraries(drv_ht PRIVATE xrt-interfaces aux_os aux_util aux_math aux_gstreamer ONNXRuntime::ONNXRuntime ${OpenCV_LIBRARIES})
ht/ht_nms.cpp
)
target_link_libraries(
drv_ht
PRIVATE
xrt-interfaces
aux_os
aux_util
aux_math
aux_gstreamer
ONNXRuntime::ONNXRuntime
${OpenCV_LIBRARIES}
)
target_include_directories(drv_ht PRIVATE ${OpenCV_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR})
list(APPEND ENABLED_DRIVERS ht)
endif()
if (XRT_BUILD_DRIVER_SURVIVE)
add_library(drv_survive STATIC
survive/survive_driver.c
survive/survive_driver.h
survive/survive_interface.h
survive/survive_prober.c)
target_link_libraries(drv_survive PRIVATE xrt-interfaces aux_os aux_util aux_math aux_vive PkgConfig::SURVIVE)
if(XRT_BUILD_DRIVER_SURVIVE)
add_library(
drv_survive STATIC survive/survive_driver.c survive/survive_driver.h
survive/survive_interface.h survive/survive_prober.c
)
target_link_libraries(
drv_survive
PRIVATE
xrt-interfaces
aux_os
aux_util
aux_math
aux_vive
PkgConfig::SURVIVE
)
list(APPEND ENABLED_HEADSET_DRIVERS survive)
if (XRT_BUILD_DRIVER_HANDTRACKING)
if(XRT_BUILD_DRIVER_HANDTRACKING)
target_link_libraries(drv_survive PRIVATE drv_ht)
endif()
endif()
if(XRT_BUILD_DRIVER_ANDROID)
add_library(drv_android STATIC
android/android_prober.c
android/android_prober.h
android/android_sensors.c
android/android_sensors.h)
target_link_libraries(drv_android PRIVATE xrt-interfaces aux_util aux_os aux_android ${ANDROID_LIBRARY})
add_library(
drv_android STATIC android/android_prober.c android/android_prober.h
android/android_sensors.c android/android_sensors.h
)
target_link_libraries(
drv_android
PRIVATE
xrt-interfaces
aux_util
aux_os
aux_android
${ANDROID_LIBRARY}
)
list(APPEND ENABLED_DRIVERS android)
endif()
if (XRT_BUILD_DRIVER_ILLIXR)
add_library(drv_illixr STATIC
if(XRT_BUILD_DRIVER_ILLIXR)
add_library(
drv_illixr STATIC
illixr/illixr_device.cpp
illixr/illixr_interface.h
illixr/illixr_prober.c
illixr/illixr_component.cpp
illixr/illixr_component.h)
illixr/illixr_component.h
)
target_link_libraries(drv_illixr PUBLIC ${CMAKE_DL_LIBS} xrt-interfaces aux_util aux_os)
target_include_directories(drv_illixr PUBLIC ${ILLIXR_PATH})
list(APPEND ENABLED_HEADSET_DRIVERS illixr)
endif()
add_library(drv_multi STATIC
multi_wrapper/multi.c
multi_wrapper/multi.h)
add_library(drv_multi STATIC multi_wrapper/multi.c multi_wrapper/multi.h)
target_link_libraries(drv_multi PUBLIC xrt-interfaces aux_util)
list(APPEND ENABLED_HEADSET_DRIVERS drv_multi)
if(XRT_BUILD_DRIVER_WMR)
add_library(drv_wmr STATIC
add_library(
drv_wmr STATIC
wmr/wmr_common.h
wmr/wmr_config.c
wmr/wmr_config.h
@ -277,18 +305,20 @@ if(XRT_BUILD_DRIVER_WMR)
wmr/wmr_interface.h
wmr/wmr_prober.c
wmr/wmr_protocol.c
wmr/wmr_protocol.h)
wmr/wmr_protocol.h
)
target_link_libraries(drv_wmr PRIVATE xrt-interfaces aux_util aux_math xrt-external-cjson)
list(APPEND ENABLED_HEADSET_DRIVERS wmr)
endif()
if(XRT_BUILD_DRIVER_EUROC)
add_library(drv_euroc STATIC
euroc/euroc_player.cpp
euroc/euroc_driver.h
euroc/euroc_device.c
euroc/euroc_interface.h)
target_link_libraries(drv_euroc PRIVATE xrt-interfaces aux_util aux_tracking ${OpenCV_LIBRARIES})
add_library(
drv_euroc STATIC euroc/euroc_player.cpp euroc/euroc_driver.h euroc/euroc_device.c
euroc/euroc_interface.h
)
target_link_libraries(
drv_euroc PRIVATE xrt-interfaces aux_util aux_tracking ${OpenCV_LIBRARIES}
)
target_include_directories(drv_euroc PRIVATE ${OpenCV_INCLUDE_DIRS})
list(APPEND ENABLED_DRIVERS euroc)
endif()
@ -296,10 +326,10 @@ endif()
if(XRT_BUILD_SAMPLES)
# We build the sample driver to make sure it stays valid,
# but it never gets linked into a final target.
add_library(drv_sample STATIC
sample/sample_hmd.c
sample/sample_interface.h
sample/sample_prober.c)
add_library(
drv_sample STATIC sample/sample_hmd.c sample/sample_interface.h
sample/sample_prober.c
)
target_link_libraries(drv_sample PRIVATE xrt-interfaces aux_util)
endif()

View file

@ -4,4 +4,6 @@
add_subdirectory(xrt)
add_library(xrt-interfaces INTERFACE)
target_include_directories(xrt-interfaces INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(
xrt-interfaces INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
)

View file

@ -1,38 +1,33 @@
# Copyright 2020, Collabora, Ltd.
# Copyright 2020-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
# Generate a header containing defines for each enabled driver
set(FILE_CONTENTS "")
foreach(DRIVER ${AVAILABLE_DRIVERS})
if(XRT_BUILD_DRIVER_${DRIVER})
string(APPEND FILE_CONTENTS "#define XRT_BUILD_DRIVER_${DRIVER}\n")
foreach(driver ${AVAILABLE_DRIVERS})
if(XRT_BUILD_DRIVER_${driver})
string(APPEND FILE_CONTENTS "#define XRT_BUILD_DRIVER_${driver}\n")
endif()
endforeach()
# First setup all of the config headers.
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/xrt_config_drivers.h.cmake_in
${CMAKE_CURRENT_BINARY_DIR}/xrt_config_drivers.h
@ONLY
${CMAKE_CURRENT_BINARY_DIR}/xrt_config_drivers.h @ONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/xrt_config_have.h.cmake_in
${CMAKE_CURRENT_BINARY_DIR}/xrt_config_have.h
@ONLY
${CMAKE_CURRENT_BINARY_DIR}/xrt_config_have.h @ONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/xrt_config_build.h.cmake_in
${CMAKE_CURRENT_BINARY_DIR}/xrt_config_build.h
@ONLY
${CMAKE_CURRENT_BINARY_DIR}/xrt_config_build.h @ONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/xrt_config_vulkan.h.cmake_in
${CMAKE_CURRENT_BINARY_DIR}/xrt_config_vulkan.h
@ONLY
${CMAKE_CURRENT_BINARY_DIR}/xrt_config_vulkan.h @ONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/xrt_config_android.h.cmake_in
${CMAKE_CURRENT_BINARY_DIR}/xrt_config_android.h
@ONLY
${CMAKE_CURRENT_BINARY_DIR}/xrt_config_android.h @ONLY
)

View file

@ -1,132 +1,114 @@
# Copyright 2020, Collabora, Ltd.
# Copyright 2020-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
###
# Generator
function(proto_gen output)
add_custom_command(OUTPUT ${output}
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shared/proto.py
foreach(
fn
ipc_protocol_generated.h
ipc_client_generated.h
ipc_client_generated.c
ipc_server_generated.h
ipc_server_generated.c
)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${fn}"
COMMAND
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shared/proto.py
${CMAKE_CURRENT_SOURCE_DIR}/shared/proto.json
${output}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/shared/proto.py
"${CMAKE_CURRENT_BINARY_DIR}/${fn}"
VERBATIM
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/shared/proto.py
${CMAKE_CURRENT_SOURCE_DIR}/shared/ipcproto/common.py
${CMAKE_CURRENT_SOURCE_DIR}/shared/proto.json
)
endfunction(proto_gen)
proto_gen(${CMAKE_CURRENT_BINARY_DIR}/ipc_protocol_generated.h)
proto_gen(${CMAKE_CURRENT_BINARY_DIR}/ipc_client_generated.h)
proto_gen(${CMAKE_CURRENT_BINARY_DIR}/ipc_client_generated.c)
proto_gen(${CMAKE_CURRENT_BINARY_DIR}/ipc_server_generated.h)
proto_gen(${CMAKE_CURRENT_BINARY_DIR}/ipc_server_generated.c)
COMMENT "Generating ${fn} from protocol JSON description"
)
endforeach()
set(IPC_COMMON_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/ipc_protocol_generated.h
shared/ipc_shmem.c
shared/ipc_shmem.h
shared/ipc_utils.c
shared/ipc_utils.h)
${CMAKE_CURRENT_BINARY_DIR}/ipc_protocol_generated.h
shared/ipc_shmem.c
shared/ipc_shmem.h
shared/ipc_utils.c
shared/ipc_utils.h
)
add_library(ipc_shared STATIC ${IPC_COMMON_SOURCES})
target_include_directories(
ipc_shared PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(ipc_shared PRIVATE aux_util)
if(RT_LIBRARY)
target_link_libraries(ipc_shared PUBLIC ${RT_LIBRARY})
endif()
###
# Client
add_library(ipc_client STATIC
add_library(
ipc_client STATIC
${CMAKE_CURRENT_BINARY_DIR}/ipc_client_generated.c
${CMAKE_CURRENT_BINARY_DIR}/ipc_client_generated.h
${IPC_COMMON_SOURCES}
client/ipc_client.h
client/ipc_client_compositor.c
client/ipc_client_device.c
client/ipc_client_hmd.c
client/ipc_client_instance.c
)
target_include_directories(ipc_client INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
target_include_directories(
ipc_client PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
)
target_include_directories(ipc_client PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(ipc_client PRIVATE
aux_util
)
if(ANDROID)
endif()
target_link_libraries(ipc_client PRIVATE aux_util ipc_shared)
###
# Server
add_library(ipc_server STATIC
add_library(
ipc_server STATIC
${CMAKE_CURRENT_BINARY_DIR}/ipc_server_generated.c
${CMAKE_CURRENT_BINARY_DIR}/ipc_server_generated.h
${IPC_COMMON_SOURCES}
server/ipc_server.h
server/ipc_server_handler.c
server/ipc_server_per_client_thread.c
server/ipc_server_process.c
)
target_include_directories(ipc_server
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
target_include_directories(
ipc_server
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
target_include_directories(ipc_server PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../compositor
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(ipc_server PRIVATE
aux_util
)
if(RT_LIBRARY)
target_link_libraries(ipc_client PRIVATE
${RT_LIBRARY}
)
target_link_libraries(ipc_server PRIVATE
${RT_LIBRARY}
)
endif()
target_link_libraries(ipc_server PRIVATE aux_util ipc_shared)
if(XRT_HAVE_SYSTEMD)
target_include_directories(ipc_server PRIVATE
${SYSTEMD_INCLUDE_DIRS})
target_link_libraries(ipc_server PRIVATE
${SYSTEMD_LIBRARIES})
target_include_directories(ipc_server PRIVATE ${SYSTEMD_INCLUDE_DIRS})
target_link_libraries(ipc_server PRIVATE ${SYSTEMD_LIBRARIES})
endif()
if(ANDROID)
add_library(ipc_android STATIC
add_library(
ipc_android STATIC
android/ipc_client_android.cpp
android/ipc_client_android.h
android/org.freedesktop.monado.ipc.cpp
android/org.freedesktop.monado.ipc.hpp
android/org.freedesktop.monado.ipc.impl.hpp
)
target_link_libraries(ipc_android PUBLIC
xrt-external-jni-wrap
xrt-external-jnipp
aux_android
target_link_libraries(
ipc_android PUBLIC xrt-external-jni-wrap xrt-external-jnipp aux_android
)
target_sources(ipc_server PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/server/ipc_server_mainloop_android.c
target_sources(
ipc_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/server/ipc_server_mainloop_android.c
)
target_link_libraries(ipc_server PUBLIC
${ANDROID_LIBRARY}
PRIVATE
aux_android
ipc_android
)
target_link_libraries(ipc_client PUBLIC
${ANDROID_LIBRARY}
PRIVATE
aux_android
ipc_android
target_link_libraries(
ipc_shared
PUBLIC ${ANDROID_LIBRARY}
PRIVATE aux_android ipc_android
)
elseif(XRT_HAVE_LINUX)
target_sources(ipc_server PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/server/ipc_server_mainloop_linux.c
target_sources(
ipc_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/server/ipc_server_mainloop_linux.c
)
endif()

View file

@ -23,25 +23,28 @@ add_library(
gui_window_record.h
)
target_link_libraries(st_gui PRIVATE xrt-external-stb aux_util aux_os aux_ogl)
target_include_directories(st_gui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../../drivers)
target_link_libraries(
st_gui
PRIVATE
xrt-external-stb
aux_util
aux_os
aux_ogl
drv_includes
xrt-external-imgui
)
target_include_directories(st_gui INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/..)
if(XRT_HAVE_GST)
target_link_libraries(st_gui PRIVATE
aux_gstreamer
)
target_link_libraries(st_gui PRIVATE aux_gstreamer)
endif()
if(XRT_BUILD_DRIVER_DEPTHAI)
target_link_libraries(st_gui PRIVATE
drv_depthai
)
target_link_libraries(st_gui PRIVATE drv_depthai)
endif()
if(XRT_BUILD_DRIVER_REMOTE)
target_link_libraries(st_gui PRIVATE
drv_remote
)
target_link_libraries(st_gui PRIVATE drv_remote)
endif()
if(XRT_HAVE_SDL2)

View file

@ -1,11 +1,12 @@
# Copyright 2019-2020, Collabora, Ltd.
# Copyright 2019-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
###
# Main code
#
set(OXR_SOURCE_FILES
add_library(
st_oxr STATIC
oxr_api_action.c
oxr_api_funcs.h
oxr_api_instance.c
@ -39,69 +40,52 @@ set(OXR_SOURCE_FILES
)
if(XRT_HAVE_VULKAN)
list(APPEND OXR_SOURCE_FILES
oxr_session_gfx_vk.c
oxr_swapchain_vk.c
oxr_vulkan.c
)
target_sources(st_oxr PRIVATE oxr_session_gfx_vk.c oxr_swapchain_vk.c oxr_vulkan.c)
target_link_libraries(st_oxr PUBLIC Vulkan::Vulkan)
endif()
if(XRT_HAVE_OPENGL)
add_definitions(-DXR_USE_GRAPHICS_API_OPENGL)
target_compile_definitions(st_oxr PRIVATE XR_USE_GRAPHICS_API_OPENGL)
endif()
if(XRT_HAVE_OPENGLES)
add_definitions(-DXR_USE_GRAPHICS_API_OPENGL_ES)
target_compile_definitions(st_oxr PRIVATE XR_USE_GRAPHICS_API_OPENGL_ES)
endif()
if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES)
list(APPEND OXR_SOURCE_FILES
oxr_session_gfx_gl.c
oxr_swapchain_gl.c
)
target_sources(st_oxr PRIVATE oxr_session_gfx_gl.c oxr_swapchain_gl.c)
target_link_libraries(st_oxr PUBLIC aux_ogl)
endif()
if(XRT_HAVE_XLIB)
add_definitions(-DXR_USE_PLATFORM_XLIB)
target_compile_definitions(st_oxr PRIVATE XR_USE_PLATFORM_XLIB)
endif()
if(XRT_HAVE_EGL)
add_definitions(-DXR_USE_PLATFORM_EGL)
list(APPEND OXR_SOURCE_FILES
oxr_session_gfx_egl.c
)
target_compile_definitions(st_oxr PRIVATE XR_USE_PLATFORM_EGL)
target_sources(st_oxr PRIVATE oxr_session_gfx_egl.c)
endif()
if(ANDROID)
add_definitions(-DXR_USE_PLATFORM_ANDROID)
list(APPEND OXR_SOURCE_FILES
oxr_session_gfx_gles_android.c
)
endif()
add_library(st_oxr STATIC ${OXR_SOURCE_FILES})
target_link_libraries(st_oxr PRIVATE
xrt-interfaces
xrt-external-openxr
aux_util
aux_math
aux_generated_bindings
comp_client
aux-includes
PUBLIC
aux_os
)
if(XRT_HAVE_VULKAN)
target_link_libraries(st_oxr PUBLIC Vulkan::Vulkan)
endif()
if(XRT_HAVE_OPENGL OR XRT_HAVE_OPENGLES)
target_link_libraries(st_oxr PUBLIC aux_ogl)
endif()
if(ANDROID)
target_compile_definitions(st_oxr PRIVATE XR_USE_PLATFORM_ANDROID)
target_sources(st_oxr PRIVATE oxr_session_gfx_gles_android.c)
target_link_libraries(st_oxr PRIVATE aux_android)
endif()
target_include_directories(st_oxr
target_link_libraries(
st_oxr
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/..)
xrt-interfaces
xrt-external-openxr
aux_util
aux_math
aux_generated_bindings
comp_client
aux-includes
PUBLIC aux_os
)
target_include_directories(
st_oxr
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/..
)

View file

@ -1,9 +1,8 @@
# Copyright 2019-2020, Collabora, Ltd.
# Copyright 2019-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
set(PROBER_INCLUDES)
set(PROBER_SOURCE_FILES
add_library(
st_prober STATIC
p_documentation.h
p_dump.c
p_prober.c
@ -11,88 +10,47 @@ set(PROBER_SOURCE_FILES
p_tracking.c
)
target_link_libraries(st_prober PUBLIC xrt-interfaces)
target_link_libraries(
st_prober
PRIVATE
drv_includes
drv_multi
aux_util
aux_os
aux_tracking
)
# Add libudev
if(XRT_HAVE_LIBUDEV)
list(APPEND PROBER_SOURCE_FILES
p_udev.c
)
target_sources(st_prober PRIVATE p_udev.c)
target_include_directories(st_prober PRIVATE ${UDEV_INCLUDE_DIRS})
target_link_libraries(st_prober PRIVATE ${UDEV_LIBRARIES})
endif()
# Add libusb
if(XRT_HAVE_LIBUSB)
list(APPEND PROBER_SOURCE_FILES
p_libusb.c
)
target_sources(st_prober PRIVATE p_libusb.c)
target_include_directories(st_prober PUBLIC ${LIBUSB1_INCLUDE_DIRS})
target_link_libraries(st_prober PRIVATE ${LIBUSB1_LIBRARIES})
endif()
# Add libuvc
if(XRT_HAVE_LIBUVC)
list(APPEND PROBER_SOURCE_FILES
p_libuvc.c
)
endif()
add_library(st_prober STATIC
${PROBER_SOURCE_FILES}
)
target_link_libraries(st_prober PUBLIC
xrt-interfaces
)
target_link_libraries(st_prober PRIVATE
drv_multi
aux_util
aux_os
aux_tracking
)
target_include_directories(st_prober PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../../drivers
)
if(XRT_HAVE_LIBUDEV)
target_include_directories(st_prober
PRIVATE
${UDEV_INCLUDE_DIRS}
)
target_link_libraries(st_prober PRIVATE
${UDEV_LIBRARIES}
)
endif()
if(XRT_HAVE_LIBUSB)
target_include_directories(st_prober
PUBLIC
${LIBUSB1_INCLUDE_DIRS}
)
target_link_libraries(st_prober PRIVATE
${LIBUSB1_LIBRARIES}
)
endif()
if(XRT_HAVE_LIBUVC)
target_include_directories(st_prober
PRIVATE
${LIBUVC_INCLUDES}
)
target_link_libraries(st_prober PRIVATE
${LIBUVC_LIBRARIES}
)
target_sources(st_prober PRIVATE p_libuvc.c)
target_include_directories(st_prober PRIVATE ${LIBUVC_INCLUDES})
target_link_libraries(st_prober PRIVATE ${LIBUVC_LIBRARIES})
endif()
if(XRT_HAVE_V4L2)
# Uses v4l2_fs_create
target_link_libraries(st_prober PRIVATE
drv_v4l2
)
target_link_libraries(st_prober PRIVATE drv_v4l2)
endif()
if(XRT_BUILD_DRIVER_REMOTE)
target_link_libraries(st_prober PRIVATE
drv_remote
)
target_link_libraries(st_prober PRIVATE drv_remote)
endif()
if(XRT_BUILD_DRIVER_VF)
target_link_libraries(st_prober PRIVATE
drv_vf
)
target_link_libraries(st_prober PRIVATE drv_vf)
endif()

View file

@ -1,20 +1,9 @@
# Copyright 2020, Collabora, Ltd.
# Copyright 2020-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
set(OVRD_SOURCE_FILES
ovrd_driver.cpp
ovrd_interface.h
)
add_library(st_ovrd STATIC ovrd_driver.cpp ovrd_interface.h)
add_library(st_ovrd STATIC
${OVRD_SOURCE_FILES}
)
target_include_directories(st_ovrd INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(st_ovrd PRIVATE
xrt-interfaces
xrt-external-openvr
aux_math
aux_generated_bindings
target_include_directories(st_ovrd INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(
st_ovrd PRIVATE xrt-interfaces xrt-external-openvr aux_math aux_generated_bindings
)

View file

@ -5,7 +5,6 @@
# This is where we collect all of the pieces from the different parts of
# the source tree and build a complete driver or integration part.
add_subdirectory(common)
if(XRT_FEATURE_OPENXR)

View file

@ -4,39 +4,23 @@
######
# Create a cli interface for Monado.
set(SOURCE_FILES
add_executable(
cli
cli_cmd_lighthouse.c
cli_cmd_probe.c
cli_cmd_test.c
cli_common.h
cli_main.c
)
add_sanitizers(cli)
if(NOT WIN32)
# No getline on Windows, so until we have a portable impl
list(APPEND SOURCE_FILES
cli_cmd_calibrate.c
)
target_sources(cli PRIVATE cli_cmd_calibrate.c)
endif()
add_executable(cli
${SOURCE_FILES}
)
add_sanitizers(cli)
set_target_properties(cli PROPERTIES OUTPUT_NAME monado-cli PREFIX "")
set_target_properties(cli PROPERTIES
OUTPUT_NAME monado-cli
PREFIX ""
)
target_link_libraries(cli PRIVATE aux_os aux_util aux_math target_instance_no_comp)
target_link_libraries(cli PRIVATE
aux_os
aux_util
aux_math
target_instance_no_comp
)
install(TARGETS cli
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(TARGETS cli RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

View file

@ -1,24 +1,19 @@
# Copyright 2019-2020, Collabora, Ltd.
# Copyright 2019-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
####
# Lists
#
add_library(target_lists STATIC
target_lists.c
)
target_link_libraries(target_lists PRIVATE
xrt-interfaces
aux_util # TODO Remove this after removing #include "util/u_time.h" from xrt_defines.h
)
target_include_directories(target_lists PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../../drivers
)
target_include_directories(target_lists PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
add_library(target_lists STATIC target_lists.c)
target_link_libraries(
target_lists
PRIVATE
xrt-interfaces
aux_util # TODO Remove this after removing #include "util/u_time.h" from xrt_defines.h
drv_includes
)
target_include_directories(target_lists PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if(XRT_BUILD_DRIVER_ARDUINO)
target_link_libraries(target_lists PRIVATE drv_arduino)
@ -114,40 +109,32 @@ endif()
# Instance
#
if(XRT_FEATURE_COMPOSITOR_MAIN)
add_library(target_instance STATIC
target_instance.c
)
target_link_libraries(target_instance PRIVATE
xrt-interfaces
aux_util
st_prober
target_lists
comp_main
)
target_include_directories(target_instance PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../../drivers
)
target_include_directories(target_instance PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
add_library(target_instance STATIC target_instance.c)
target_link_libraries(
target_instance
PRIVATE
xrt-interfaces
aux_util
st_prober
target_lists
comp_main
drv_includes
)
target_include_directories(target_instance PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
endif()
####
# Instance without Compositor
#
add_library(target_instance_no_comp STATIC
target_instance_no_comp.c
)
target_link_libraries(target_instance_no_comp PRIVATE
xrt-interfaces
aux_util
st_prober
target_lists
)
target_include_directories(target_instance_no_comp PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../../drivers
)
target_include_directories(target_instance_no_comp PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
add_library(target_instance_no_comp STATIC target_instance_no_comp.c)
target_link_libraries(
target_instance_no_comp
PRIVATE
xrt-interfaces
aux_util
st_prober
target_lists
drv_includes
)
target_include_directories(target_instance_no_comp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

View file

@ -1,22 +1,11 @@
# Copyright 2020-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
add_executable(monado-ctl
main.c
)
add_executable(monado-ctl main.c)
add_sanitizers(monado-ctl)
target_include_directories(monado-ctl PRIVATE
ipc
)
target_include_directories(monado-ctl PRIVATE ipc)
target_link_libraries(monado-ctl PRIVATE
aux_util
ipc_client
)
install(TARGETS monado-ctl
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
target_link_libraries(monado-ctl PRIVATE aux_util ipc_client)
install(TARGETS monado-ctl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

View file

@ -11,13 +11,14 @@ add_sanitizers(gui)
target_link_libraries(
gui
PRIVATE aux_os
aux_ogl
aux_util
aux_math
st_gui
target_instance_no_comp
xrt-external-imgui-sdl2
PRIVATE
aux_os
aux_ogl
aux_util
aux_math
st_gui
target_instance_no_comp
xrt-external-imgui-sdl2
)
if(WIN32)
target_link_libraries(gui PRIVATE SDL2::SDL2main)

View file

@ -7,89 +7,60 @@
set(RUNTIME_BARE_SUFFIX monado)
set(RUNTIME_SUFFIX _${RUNTIME_BARE_SUFFIX})
set(RUNTIME_TARGET ${RUNTIME_PREFIX}openxr${RUNTIME_SUFFIX} CACHE INTERNAL "" FORCE)
set(RUNTIME_TARGET
${RUNTIME_PREFIX}openxr${RUNTIME_SUFFIX}
CACHE INTERNAL "" FORCE
)
# OpenXR 1.0
set(XR_API_MAJOR "1")
set(SOURCE_FILES
target.c
oxr_sdl2_hack.c
libopenxr.def
)
# depends on above generated files
add_library(${RUNTIME_TARGET} MODULE
${MANIFEST_DEV_PATH}
${MANIFEST_PATH}
${SOURCE_FILES}
)
add_library(${RUNTIME_TARGET} MODULE target.c libopenxr.def)
# Note: Order may matter in these lists!
target_link_libraries(${RUNTIME_TARGET} PUBLIC
aux_vk
aux_os
aux_util
aux_math
)
if(XRT_HAVE_OPENGL)
target_link_libraries(${RUNTIME_TARGET} PUBLIC aux_ogl)
endif()
if(XRT_HAVE_SDL2)
target_link_libraries(${RUNTIME_TARGET} PRIVATE st_gui xrt-external-imgui-sdl2 ${SDL2_LIBRARIES})
if(XRT_BUILD_DRIVER_QWERTY)
target_link_libraries(${RUNTIME_TARGET} PRIVATE
drv_qwerty
drv_qwerty_includes
)
endif()
endif()
target_link_libraries(${RUNTIME_TARGET} PUBLIC aux_vk aux_os aux_util aux_math)
if(XRT_FEATURE_SERVICE)
target_link_libraries(${RUNTIME_TARGET} PUBLIC
st_oxr
ipc_client
comp_client
)
target_link_libraries(${RUNTIME_TARGET} PUBLIC st_oxr ipc_client comp_client)
else()
target_link_libraries(${RUNTIME_TARGET} PUBLIC
st_oxr
st_prober
target_lists
target_instance
comp_main
comp_client
target_link_libraries(
${RUNTIME_TARGET}
PUBLIC
st_oxr
st_prober
target_lists
target_instance
comp_main
comp_client
)
endif()
if(NOT MSVC)
# Force the main "negotiate" symbol's inclusion
# and use a version script to ensure that's the only one we expose.
set_property(TARGET ${RUNTIME_TARGET}
set_property(
TARGET ${RUNTIME_TARGET}
APPEND_STRING
PROPERTY LINK_FLAGS
"-u xrNegotiateLoaderRuntimeInterface -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libopenxr.version")
PROPERTY
LINK_FLAGS
"-u xrNegotiateLoaderRuntimeInterface -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libopenxr.version"
)
# Re-link if the version script changes.
set_property(TARGET ${RUNTIME_TARGET}
set_property(
TARGET ${RUNTIME_TARGET}
APPEND
PROPERTY LINK_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/libopenxr.version")
PROPERTY LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/libopenxr.version"
)
endif()
# Install the runtime itself
install(TARGETS ${RUNTIME_TARGET}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
install(
TARGETS ${RUNTIME_TARGET} #
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} #
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} #
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# $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
set(MANIFEST_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/openxr_monado.in.json)
@ -116,9 +87,11 @@ else()
set(DEV_MANIFEST_OUTPUT "${CMAKE_BINARY_DIR}/${RUNTIME_TARGET}-dev.json")
endif()
file(GENERATE
file(
GENERATE
OUTPUT "${DEV_MANIFEST_OUTPUT}"
INPUT ${CMAKE_CURRENT_BINARY_DIR}/intermediate_manifest.json)
INPUT ${CMAKE_CURRENT_BINARY_DIR}/intermediate_manifest.json
)
###
# Prepare the installable manifest: will be generated completely at install time,
@ -126,7 +99,9 @@ file(GENERATE
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(MANIFEST_RELATIVE_DIR share/openxr/${XR_API_MAJOR}/)
if(XRT_OPENXR_INSTALL_ACTIVE_RUNTIME)
configure_file(active_runtime.cmake ${CMAKE_CURRENT_BINARY_DIR}/active_runtime.cmake @ONLY)
configure_file(
active_runtime.cmake ${CMAKE_CURRENT_BINARY_DIR}/active_runtime.cmake @ONLY
)
install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/active_runtime.cmake)
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
@ -137,7 +112,25 @@ endif()
# If we know where to install the manifest, we can set it up to be installed.
if(MANIFEST_RELATIVE_DIR)
set(RUNTIME_RELATIVE_DIR ${CMAKE_INSTALL_LIBDIR})
set(RUNTIME_FILENAME ${CMAKE_SHARED_MODULE_PREFIX}${RUNTIME_TARGET}${CMAKE_SHARED_MODULE_SUFFIX})
set(RUNTIME_FILENAME
${CMAKE_SHARED_MODULE_PREFIX}${RUNTIME_TARGET}${CMAKE_SHARED_MODULE_SUFFIX}
)
configure_file(make_manifest.cmake ${CMAKE_CURRENT_BINARY_DIR}/make_manifest.cmake @ONLY)
install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/make_manifest.cmake)
endif()
###
# Inelegant but effective SDL2-based debug GUI
add_library(oxr_sdl2 STATIC oxr_sdl2_hack.c)
target_link_libraries(oxr_sdl2 PRIVATE aux_util)
if(XRT_HAVE_OPENGL)
target_link_libraries(oxr_sdl2 PUBLIC aux_ogl)
endif()
if(XRT_HAVE_SDL2)
target_link_libraries(oxr_sdl2 PRIVATE st_gui xrt-external-imgui-sdl2 ${SDL2_LIBRARIES})
if(XRT_BUILD_DRIVER_QWERTY)
target_link_libraries(oxr_sdl2 PRIVATE drv_qwerty drv_qwerty_includes)
endif()
endif()
target_link_libraries(${RUNTIME_TARGET} PRIVATE oxr_sdl2)

View file

@ -7,12 +7,14 @@ set(MANIFEST_RELATIVE_DIR @MANIFEST_RELATIVE_DIR@)
set(XR_API_MAJOR @XR_API_MAJOR@)
set(RUNTIME_TARGET @RUNTIME_TARGET@)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_INSTALL_PREFIX}/${MANIFEST_RELATIVE_DIR}/${RUNTIME_TARGET}.json
${CMAKE_BINARY_DIR}/active_runtime.json)
execute_process(
COMMAND
${CMAKE_COMMAND} -E create_symlink
${CMAKE_INSTALL_PREFIX}/${MANIFEST_RELATIVE_DIR}/${RUNTIME_TARGET}.json
${CMAKE_BINARY_DIR}/active_runtime.json
)
file(
INSTALL
DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/xdg/openxr/${XR_API_MAJOR}"
TYPE FILE
FILES "${CMAKE_BINARY_DIR}/active_runtime.json"
)
TYPE FILE FILES "${CMAKE_BINARY_DIR}/active_runtime.json"
)

View file

@ -13,26 +13,27 @@ set(XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH @XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIM
string(REGEX REPLACE "/$" "" MANIFEST_RELATIVE_DIR "${MANIFEST_RELATIVE_DIR}")
if(XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH)
# Absolute path to runtime
set(RUNTIME_PATH ${RUNTIME_RELATIVE_DIR}/${RUNTIME_FILENAME})
if(NOT IS_ABSOLUTE ${RUNTIME_RELATIVE_DIR})
set(RUNTIME_PATH ${CMAKE_INSTALL_PREFIX}/${RUNTIME_PATH})
endif()
# Absolute path to runtime
set(RUNTIME_PATH ${RUNTIME_RELATIVE_DIR}/${RUNTIME_FILENAME})
if(NOT IS_ABSOLUTE ${RUNTIME_RELATIVE_DIR})
set(RUNTIME_PATH ${CMAKE_INSTALL_PREFIX}/${RUNTIME_PATH})
endif()
else()
# Relative path to runtime: requires it exist on the system shared library search path.
set(RUNTIME_PATH ${RUNTIME_FILENAME})
# Relative path to runtime: requires it exist on the system shared library search path.
set(RUNTIME_PATH ${RUNTIME_FILENAME})
endif()
set(runtime_path ${RUNTIME_PATH})
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
# Create manifest
configure_file(${MANIFEST_INPUT} ${CMAKE_CURRENT_LIST_DIR}/@RUNTIME_TARGET@.json)
# Create manifest
configure_file(${MANIFEST_INPUT} ${CMAKE_CURRENT_LIST_DIR}/@RUNTIME_TARGET@.json)
# Install it
file(INSTALL
DESTINATION "${CMAKE_INSTALL_PREFIX}/${MANIFEST_RELATIVE_DIR}"
TYPE FILE
FILES "${CMAKE_CURRENT_LIST_DIR}/@RUNTIME_TARGET@.json")
# Install it
file(
INSTALL
DESTINATION "${CMAKE_INSTALL_PREFIX}/${MANIFEST_RELATIVE_DIR}"
TYPE FILE FILES "${CMAKE_CURRENT_LIST_DIR}/@RUNTIME_TARGET@.json"
)
endif()

View file

@ -1,17 +1,16 @@
# Copyright 2020, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
add_library(monado-service MODULE service_target.cpp)
add_library(monado-service MODULE
service_target.cpp
)
target_link_libraries(monado-service PRIVATE
aux_util
st_prober
ipc_server
comp_main
target_lists
target_instance
xrt-external-jni-wrap
target_link_libraries(
monado-service
PRIVATE
aux_util
st_prober
ipc_server
comp_main
target_lists
target_instance
xrt-external-jni-wrap
)

View file

@ -1,53 +1,59 @@
# Copyright 2020, Collabora, Ltd.
# Copyright 2020-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
add_executable(monado-service
main.c
../openxr/oxr_sdl2_hack.c
)
add_executable(monado-service main.c)
add_sanitizers(monado-service)
target_link_libraries(monado-service PRIVATE
aux_util
st_prober
ipc_server
comp_main
target_lists
target_instance
target_link_libraries(
monado-service
PRIVATE
aux_util
st_prober
ipc_server
comp_main
target_lists
target_instance
oxr_sdl2
)
install(TARGETS monado-service
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(TARGETS monado-service RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if(XRT_HAVE_SYSTEMD)
set(SERVICE_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/monado.in.service)
set(SOCKET_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/monado.in.socket)
set(SERVICE_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/monado.in.service")
set(SOCKET_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/monado.in.socket")
###
# Generate systemd unit files with absolute path to service intended for development without installing
# Generate systemd unit files with absolute path to service
# intended for development without installing
set(UNIT_NAME monado-dev)
set(service_path $<TARGET_FILE:monado-service>)
set(conflicts monado)
set(exit_on_disconnect ON)
set(extra_desc "in build tree")
configure_file(${SOCKET_INPUT} ${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}.socket)
# Need this step because file(GENERATE) only evaluates generator expressions, and not what configure_file does.
configure_file(${SERVICE_INPUT} ${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}-intermediate.service)
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}.service"
INPUT ${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}-intermediate.service)
configure_file(${SOCKET_INPUT} "${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}.socket")
configure_file(${SOCKET_INPUT} ${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}.socket @ONLY)
# Need this step because file(GENERATE) only evaluates generator expressions,
# and not what configure_file does.
configure_file(
${SERVICE_INPUT} "${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}-intermediate.service"
)
file(
GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}.service"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}-intermediate.service"
)
configure_file(${SOCKET_INPUT} "${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}.socket" @ONLY)
# Make a custom target to link those in.
add_custom_target(link-systemd-dev-units
COMMAND systemctl --user link ${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}.socket
COMMAND systemctl --user link ${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}.service
add_custom_target(
link-systemd-dev-units
COMMAND systemctl --user link "${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}.socket"
COMMAND systemctl --user link "${CMAKE_CURRENT_BINARY_DIR}/${UNIT_NAME}.service"
COMMAND systemctl --user daemon-reload
VERBATIM
COMMENT "Linking monado-dev.{socket,service} into your local systemd unit directory."
)
COMMENT
"Linking monado-dev.{socket,service} into your local systemd unit directory."
)
endif()
if(XRT_INSTALL_SYSTEMD_UNIT_FILES)
@ -63,9 +69,18 @@ if(XRT_INSTALL_SYSTEMD_UNIT_FILES)
set(XRT_SYSTEMD_UNIT_INSTALL_DIR lib/systemd/user)
if(PC_SYSTEMD_USERUNITDIR AND PC_SYSTEMD_PREFIX)
# Strip prefix
string(REGEX REPLACE "^${PC_SYSTEMD_PREFIX}/" "" XRT_SYSTEMD_UNIT_INSTALL_DIR "${PC_SYSTEMD_USERUNITDIR}")
string(
REGEX
REPLACE "^${PC_SYSTEMD_PREFIX}/" "" XRT_SYSTEMD_UNIT_INSTALL_DIR
"${PC_SYSTEMD_USERUNITDIR}"
)
endif()
set(XRT_SYSTEMD_UNIT_INSTALL_DIR "${XRT_SYSTEMD_UNIT_INSTALL_DIR}" CACHE STRING "The (absolute, or CMAKE_INSTALL_PREFIX-relative) path to install the systemd user unit files.")
set(XRT_SYSTEMD_UNIT_INSTALL_DIR
"${XRT_SYSTEMD_UNIT_INSTALL_DIR}"
CACHE
STRING
"The (absolute, or CMAKE_INSTALL_PREFIX-relative) path to install the systemd user unit files."
)
mark_as_advanced(XRT_SYSTEMD_UNIT_INSTALL_DIR)
endif()
if(XRT_SYSTEMD_UNIT_INSTALL_DIR MATCHES "^/")
@ -75,12 +90,17 @@ if(XRT_INSTALL_SYSTEMD_UNIT_FILES)
# Destination is relative: prepend destdir (implicitly) and install prefix at install time
set(UNIT_DIR "\${CMAKE_INSTALL_PREFIX}/${XRT_SYSTEMD_UNIT_INSTALL_DIR}")
endif()
configure_file(configure_and_install_units.cmake ${CMAKE_CURRENT_BINARY_DIR}/configure_and_install_units.cmake @ONLY)
configure_file(
configure_and_install_units.cmake
${CMAKE_CURRENT_BINARY_DIR}/configure_and_install_units.cmake @ONLY
)
# This script will configure the units and install them at install time.
install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/configure_and_install_units.cmake)
endif()
if(XRT_HAVE_SDL2)
target_link_libraries(monado-service PRIVATE st_gui xrt-external-imgui-sdl2 aux_ogl drv_qwerty_includes)
target_link_libraries(
monado-service PRIVATE st_gui xrt-external-imgui-sdl2 aux_ogl drv_qwerty_includes
)
endif()

View file

@ -8,8 +8,7 @@ set(conflicts @conflicts@)
set(exit_on_disconnect @exit_on_disconnect@)
set(service_path "monado-service")
if(XRT_INSTALL_ABSOLUTE_SYSTEMD_UNIT_FILES)
set(service_path
"${CMAKE_INSTALL_PREFIX}/@CMAKE_INSTALL_BINDIR@/${service_path}")
set(service_path "${CMAKE_INSTALL_PREFIX}/@CMAKE_INSTALL_BINDIR@/${service_path}")
endif()
# Create unit files
@ -18,9 +17,11 @@ configure_file(@SERVICE_INPUT@ "@CMAKE_CURRENT_BINARY_DIR@/@UNIT_NAME@.service")
# Install them
file(
INSTALL
DESTINATION "@UNIT_DIR@"
TYPE FILE
FILES
"@CMAKE_CURRENT_BINARY_DIR@/@UNIT_NAME@.socket"
"@CMAKE_CURRENT_BINARY_DIR@/@UNIT_NAME@.service")
INSTALL
DESTINATION "@UNIT_DIR@"
TYPE
FILE
FILES
"@CMAKE_CURRENT_BINARY_DIR@/@UNIT_NAME@.socket"
"@CMAKE_CURRENT_BINARY_DIR@/@UNIT_NAME@.service"
)

View file

@ -1,78 +1,71 @@
# Copyright 2020, Collabora, Ltd.
# Copyright 2020-2021, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
get_property(AUX_BINDINGS_DIR GLOBAL PROPERTY AUX_BINDINGS_DIR_PROP)
set(INPUT_PROFILES_INPUT_DIR ${AUX_BINDINGS_DIR})
set(INPUT_PROFILES_OUTPUT_DIR "${PROJECT_BINARY_DIR}/steamvr-monado/resources/input/")
function(input_profiles_gen output custom_target)
add_custom_command(OUTPUT ${output}
COMMAND ${PYTHON_EXECUTABLE} ${INPUT_PROFILES_INPUT_DIR}/steamvr_profiles.py
${INPUT_PROFILES_INPUT_DIR}/bindings.json
${output}
DEPENDS ${INPUT_PROFILES_INPUT_DIR}/bindings.py
${INPUT_PROFILES_INPUT_DIR}/bindings.json
)
add_custom_target(${custom_target} DEPENDS ${output})
endfunction(input_profiles_gen)
input_profiles_gen(${INPUT_PROFILES_OUTPUT_DIR} generated_input_profiles)
add_custom_command(
OUTPUT "${INPUT_PROFILES_OUTPUT_DIR}"
COMMAND
${PYTHON_EXECUTABLE} ${INPUT_PROFILES_INPUT_DIR}/steamvr_profiles.py
${INPUT_PROFILES_INPUT_DIR}/bindings.json "${INPUT_PROFILES_OUTPUT_DIR}"
DEPENDS ${INPUT_PROFILES_INPUT_DIR}/bindings.py ${INPUT_PROFILES_INPUT_DIR}/bindings.json
COMMENT "Generating SteamVR input profiles to ${INPUT_PROFILES_OUTPUT_DIR}"
)
add_custom_target(
steamvr_generated_input_profiles
DEPENDS "${INPUT_PROFILES_OUTPUT_DIR}"
COMMENT "Generating SteamVR input profiles"
)
add_library(driver_monado MODULE main.c)
add_dependencies(driver_monado generated_input_profiles)
add_dependencies(driver_monado steamvr_generated_input_profiles)
target_link_libraries(
driver_monado PRIVATE xrt-external-openvr aux_util st_ovrd st_prober target_lists target_instance_no_comp
driver_monado
PRIVATE
xrt-external-openvr
aux_util
st_ovrd
st_prober
target_lists
target_instance_no_comp
)
# meta data that the steamvr plugin needs in the base directory of the steamvr plugin
file(COPY driver.vrdrivermanifest DESTINATION ${PROJECT_BINARY_DIR}/steamvr-monado)
file(COPY resources DESTINATION ${PROJECT_BINARY_DIR}/steamvr-monado)
#determine the output directory for the steamvr plugin
# determine the output directory for the steamvr plugin
if(WIN32)
# FIXME need to account for different architectures
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(PLUGINDIR
${PROJECT_BINARY_DIR}/steamvr-monado/bin/win64
CACHE INTERNAL ""
)
set(PLUGINDIR "${PROJECT_BINARY_DIR}/steamvr-monado/bin/win64")
else()
set(PLUGINDIR
${PROJECT_BINARY_DIR}/steamvr-monado/bin/win32
CACHE INTERNAL ""
)
set(PLUGINDIR "${PROJECT_BINARY_DIR}/steamvr-monado/bin/win32")
endif()
elseif(APPLE)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(PLUGINDIR
${PROJECT_BINARY_DIR}/steamvr-monado/bin/osx64
CACHE INTERNAL ""
)
set(PLUGINDIR "${PROJECT_BINARY_DIR}/steamvr-monado/bin/osx64")
else()
set(PLUGINDIR
${PROJECT_BINARY_DIR}/steamvr-monado/bin/osx32
CACHE INTERNAL ""
)
set(PLUGINDIR "${PROJECT_BINARY_DIR}/steamvr-monado/bin/osx32")
endif()
elseif(NOT ANDROID)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(PLUGINDIR
${PROJECT_BINARY_DIR}/steamvr-monado/bin/linux64
CACHE INTERNAL ""
)
set(PLUGINDIR "${PROJECT_BINARY_DIR}/steamvr-monado/bin/linux64")
else()
set(PLUGINDIR
${PROJECT_BINARY_DIR}/steamvr-monado/bin/linux32
CACHE INTERNAL ""
)
set(PLUGINDIR "${PROJECT_BINARY_DIR}/steamvr-monado/bin/linux32")
endif()
endif()
message("SteamVR plugin path: ${PLUGINDIR}")
# message("SteamVR plugin path: ${PLUGINDIR}")
set_target_properties(driver_monado PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${PLUGINDIR}")
# don't add lib prefix to driver_monado.so
set_target_properties(driver_monado PROPERTIES PREFIX "")
install(DIRECTORY "${PROJECT_BINARY_DIR}/steamvr-monado" DESTINATION "${CMAKE_INSTALL_PREFIX}/share")
install(
DIRECTORY "${PROJECT_BINARY_DIR}/steamvr-monado"
DESTINATION "${CMAKE_INSTALL_PREFIX}/share"
)

View file

@ -9,15 +9,12 @@ if(ANDROID)
target_link_libraries(tests_main PUBLIC log)
endif()
# Input transform test
add_executable(tests_input_transform tests_input_transform.cpp)
target_link_libraries(tests_input_transform PRIVATE tests_main)
target_link_libraries(tests_input_transform PRIVATE
st_oxr
xrt-interfaces
xrt-external-openxr
aux_util)
target_link_libraries(
tests_input_transform PRIVATE st_oxr xrt-interfaces xrt-external-openxr aux_util
)
add_test(NAME input_transform COMMAND tests_input_transform --success)
# Generic callbacks