From e2c6fbdd9a7d7813ec9b90964e7a03d2c925b583 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Wed, 3 Nov 2021 15:06:26 -0500 Subject: [PATCH] cmake: Inline lists of sources for drivers, per current best practice --- src/xrt/drivers/CMakeLists.txt | 167 +++++++++++---------------------- 1 file changed, 53 insertions(+), 114 deletions(-) diff --git a/src/xrt/drivers/CMakeLists.txt b/src/xrt/drivers/CMakeLists.txt index f239c9f76..5b4c92198 100644 --- a/src/xrt/drivers/CMakeLists.txt +++ b/src/xrt/drivers/CMakeLists.txt @@ -1,4 +1,5 @@ -# Copyright 2019-2020, Collabora, Ltd. +# Copyright 2019-2021, Collabora, Ltd. +# # SPDX-License-Identifier: BSL-1.0 @@ -6,37 +7,28 @@ set(ENABLED_HEADSET_DRIVERS) set(ENABLED_DRIVERS) if(XRT_BUILD_DRIVER_ARDUINO) - set(ARDUINO_SOURCE_FILES + add_library(drv_arduino STATIC arduino/arduino_device.c arduino/arduino_interface.h - arduino/arduino_prober.c - ) - - add_library(drv_arduino STATIC ${ARDUINO_SOURCE_FILES}) + 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) - set(DAYDREAM_SOURCE_FILES + 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_SOURCE_FILES}) + 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) - set(DEPTHAI_SOURCE_FILES + add_library(drv_depthai STATIC depthai/depthai_driver.cpp - depthai/depthai_interface.h - ) - - add_library(drv_depthai STATIC ${DEPTHAI_SOURCE_FILES}) + depthai/depthai_interface.h) target_link_libraries(drv_depthai PRIVATE xrt-interfaces aux_os @@ -50,27 +42,21 @@ if(XRT_BUILD_DRIVER_DEPTHAI) endif() if(XRT_BUILD_DRIVER_DUMMY) - set(DUMMY_SOURCE_FILES + add_library(drv_dummy STATIC dummy/dummy_hmd.c dummy/dummy_interface.h - dummy/dummy_prober.c - ) - - add_library(drv_dummy STATIC ${DUMMY_SOURCE_FILES}) + 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) - set(QWERTY_SOURCE_FILES + 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 - ) - - add_library(drv_qwerty STATIC ${QWERTY_SOURCE_FILES}) + qwerty/qwerty_sdl.c) target_link_libraries(drv_qwerty PRIVATE xrt-interfaces aux_util @@ -87,13 +73,13 @@ endif() if(XRT_BUILD_DRIVER_HDK) 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_SOURCE_FILES}) + hdk/hdk_prober.c) target_link_libraries(drv_hdk PRIVATE xrt-interfaces aux_math) list(APPEND ENABLED_HEADSET_DRIVERS hdk) endif() @@ -101,49 +87,41 @@ endif() if(XRT_BUILD_DRIVER_HYDRA) set(HYDRA_SOURCE_FILES - hydra/hydra_driver.c - hydra/hydra_interface.h ) - add_library(drv_hydra STATIC ${HYDRA_SOURCE_FILES}) + 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) - set(NS_SOURCE_FILES + 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 - ) - - add_library(drv_ns STATIC ${NS_SOURCE_FILES}) + 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) - set(ULV2_SOURCE_FILES + add_library(drv_ulv2 STATIC ultraleap_v2/ulv2_driver.cpp - ultraleap_v2/ulv2_interface.h - ) - add_library(drv_ulv2 STATIC ${ULV2_SOURCE_FILES}) + 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) - set(OHMD_SOURCE_FILES + 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_SOURCE_FILES}) + 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() @@ -151,55 +129,43 @@ endif() if(XRT_BUILD_DRIVER_PSMV) - set(PSMOVE_SOURCE_FILES + add_library(drv_psmv STATIC psmv/psmv_driver.c - psmv/psmv_interface.h - ) - - add_library(drv_psmv STATIC ${PSMOVE_SOURCE_FILES}) + 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) - set(PSVR_SOURCE_FILES + 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 - ) - - add_library(drv_psvr STATIC ${PSVR_SOURCE_FILES}) + 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) - set(RS_SOURCE_FILES + 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 - ) - - add_library(drv_rs STATIC ${RS_SOURCE_FILES}) + 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) - set(REMOTE_SOURCE_FILES + 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 - ) - - add_library(drv_remote STATIC ${REMOTE_SOURCE_FILES}) + remote/r_internal.h) target_link_libraries(drv_remote PRIVATE xrt-interfaces aux_util) list(APPEND ENABLED_HEADSET_DRIVERS remote) endif() @@ -207,6 +173,9 @@ endif() set(VIVE_CONFIG_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/vive") if(XRT_BUILD_DRIVER_VIVE) set(VIVE_SOURCE_FILES + ) + + add_library(drv_vive STATIC vive/vive_device.h vive/vive_device.c vive/vive_prober.h @@ -216,10 +185,7 @@ if(XRT_BUILD_DRIVER_VIVE) vive/vive_controller.h vive/vive_controller.c vive/vive_lighthouse.h - vive/vive_lighthouse.c - ) - - add_library(drv_vive STATIC ${VIVE_SOURCE_FILES}) + 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}) @@ -231,11 +197,7 @@ if(XRT_BUILD_DRIVER_VIVE) endif() if(XRT_HAVE_V4L2) - set(V4L2_SOURCE_FILES - v4l2/v4l2_driver.c - ) - - add_library(drv_v4l2 STATIC ${V4L2_SOURCE_FILES}) + add_library(drv_v4l2 STATIC v4l2/v4l2_driver.c) target_link_libraries(drv_v4l2 PRIVATE xrt-interfaces aux_os @@ -245,18 +207,14 @@ if(XRT_HAVE_V4L2) endif() if(XRT_BUILD_DRIVER_VF) - set(VF_SOURCE_FILES - vf/vf_driver.c - ) - - add_library(drv_vf STATIC ${VF_SOURCE_FILES}) + add_library(drv_vf STATIC vf/vf_driver.c) target_link_libraries(drv_vf PRIVATE xrt-interfaces aux_os aux_util ${GST_LIBRARIES}) target_include_directories(drv_vf PRIVATE ${GST_INCLUDE_DIRS}) list(APPEND ENABLED_DRIVERS vf) endif() if(XRT_BUILD_DRIVER_HANDTRACKING) - set(HT_SOURCE_FILES + add_library(drv_ht STATIC ht/ht_driver.cpp ht/ht_driver.hpp ht/ht_interface.h @@ -264,23 +222,18 @@ if(XRT_BUILD_DRIVER_HANDTRACKING) ht/ht_hand_math.hpp ht/ht_image_math.hpp ht/ht_nms.hpp - ht/templates/NaivePermutationSort.hpp - ) - add_library(drv_ht STATIC ${HT_SOURCE_FILES}) + ht/templates/NaivePermutationSort.hpp) 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) - set(SURVIVE_SOURCE_FILES + add_library(drv_survive STATIC survive/survive_driver.c survive/survive_driver.h survive/survive_interface.h - survive/survive_prober.c - ) - - add_library(drv_survive STATIC ${SURVIVE_SOURCE_FILES}) + 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) @@ -290,43 +243,35 @@ if (XRT_BUILD_DRIVER_SURVIVE) endif() if(XRT_BUILD_DRIVER_ANDROID) - set(ANDROID_SOURCE_FILES + add_library(drv_android STATIC android/android_prober.c android/android_prober.h android/android_sensors.c - android/android_sensors.h - ) - - add_library(drv_android STATIC ${ANDROID_SOURCE_FILES}) + 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) - set(ILLIXR_SOURCE_FILES + 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 - ) - - add_library(drv_illixr STATIC ${ILLIXR_SOURCE_FILES}) + 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() -set(MUlTI_SOURCE_FILES +add_library(drv_multi STATIC multi_wrapper/multi.c - multi_wrapper/multi.h - ) -add_library(drv_multi STATIC ${MUlTI_SOURCE_FILES}) + 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) - set(WMR_SOURCE_FILES + add_library(drv_wmr STATIC wmr/wmr_common.h wmr/wmr_config.c wmr/wmr_config.h @@ -335,23 +280,17 @@ if(XRT_BUILD_DRIVER_WMR) wmr/wmr_interface.h wmr/wmr_prober.c wmr/wmr_protocol.c - wmr/wmr_protocol.h - ) - - add_library(drv_wmr STATIC ${WMR_SOURCE_FILES}) + 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) - set(EUROC_SOURCE_FILES + add_library(drv_euroc STATIC euroc/euroc_player.cpp euroc/euroc_driver.h euroc/euroc_device.c - euroc/euroc_interface.h - ) - - add_library(drv_euroc STATIC ${EUROC_SOURCE_FILES}) + 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)