From 13b154580b980cdc8fbec3d65308faa942a67d5c Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Sat, 23 Jul 2022 17:15:56 +0000 Subject: [PATCH] ci, cmake: add optional dep for bluetooth --- .gitlab-ci.yml | 14 ++++----- .gitlab-ci/config.yml | 10 +++--- CMakeLists.txt | 3 ++ cmake/Findbluetooth.cmake | 66 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 cmake/Findbluetooth.cmake diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a3c105caa..319b88085 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,26 +30,26 @@ include: .monado.variables.debian:bullseye: variables: FDO_DISTRIBUTION_VERSION: "bullseye" - FDO_DISTRIBUTION_TAG: "2022-04-22.0" + FDO_DISTRIBUTION_TAG: "2022-07-25.0" # Variables for build and usage of Debian bullseye-ndk image .monado.variables.debian:bullseye-ndk: variables: FDO_DISTRIBUTION_VERSION: "bullseye" - FDO_DISTRIBUTION_TAG: "2022-06-27.0" + FDO_DISTRIBUTION_TAG: "2022-07-25.0" FDO_REPO_SUFFIX: ndk # Variables for build and usage of Ubuntu focal image .monado.variables.ubuntu:focal: variables: FDO_DISTRIBUTION_VERSION: "20.04" - FDO_DISTRIBUTION_TAG: "2022-07-24.0" + FDO_DISTRIBUTION_TAG: "2022-07-25.0" # Variables for build and usage of Arch rolling image .monado.variables.arch:rolling: variables: FDO_DISTRIBUTION_VERSION: "rolling" - FDO_DISTRIBUTION_TAG: "2022-04-22.0" + FDO_DISTRIBUTION_TAG: "2022-07-25.0" stages: - container_prep @@ -71,7 +71,7 @@ debian:bullseye:container_prep: changes: - .gitlab-ci/**/* variables: - FDO_DISTRIBUTION_PACKAGES: 'build-essential ca-certificates clang-format cmake codespell curl debhelper devscripts doxygen dput-ng gettext-base git glslang-tools graphviz libavcodec-dev libbsd-dev libcjson-dev libdbus-1-dev libegl1-mesa-dev libeigen3-dev libgl1-mesa-dev libglvnd-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libhidapi-dev libopencv-dev libsdl2-dev libsystemd-dev libudev-dev libusb-1.0-0-dev libuvc-dev libv4l-dev libvulkan-dev libwayland-dev libx11-dev libx11-xcb-dev libxcb-randr0-dev libxrandr-dev libxxf86vm-dev ninja-build pandoc patch pkg-config python3 python3-click python3-pip unzip wget' + FDO_DISTRIBUTION_PACKAGES: 'build-essential ca-certificates clang-format cmake codespell curl debhelper devscripts doxygen dput-ng gettext-base git glslang-tools graphviz libavcodec-dev libbluetooth-dev libbsd-dev libcjson-dev libdbus-1-dev libegl1-mesa-dev libeigen3-dev libgl1-mesa-dev libglvnd-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libhidapi-dev libopencv-dev libsdl2-dev libsystemd-dev libudev-dev libusb-1.0-0-dev libuvc-dev libv4l-dev libvulkan-dev libwayland-dev libx11-dev libx11-xcb-dev libxcb-randr0-dev libxrandr-dev libxxf86vm-dev ninja-build pandoc patch pkg-config python3 python3-click python3-pip unzip wget' FDO_DISTRIBUTION_EXEC: 'bash .gitlab-ci/i386_and_proclamation_container_prep.sh' # Make Debian bullseye-ndk image @@ -97,7 +97,7 @@ ubuntu:focal:container_prep: changes: - .gitlab-ci/**/* variables: - FDO_DISTRIBUTION_PACKAGES: 'build-essential ca-certificates cmake curl debhelper devscripts dput-ng gettext-base git glslang-tools libavcodec-dev libbsd-dev libcjson-dev libdbus-1-dev libegl1-mesa-dev libeigen3-dev libgl1-mesa-dev libglvnd-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libhidapi-dev libopencv-dev libsdl2-dev libsystemd-dev libudev-dev libusb-1.0-0-dev libuvc-dev libv4l-dev libvulkan-dev libwayland-dev libx11-dev libx11-xcb-dev libxcb-randr0-dev libxrandr-dev libxxf86vm-dev ninja-build pandoc patch pkg-config python3 reprepro unzip wget' + FDO_DISTRIBUTION_PACKAGES: 'build-essential ca-certificates cmake curl debhelper devscripts dput-ng gettext-base git glslang-tools libavcodec-dev libbluetooth-dev libbsd-dev libcjson-dev libdbus-1-dev libegl1-mesa-dev libeigen3-dev libgl1-mesa-dev libglvnd-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libhidapi-dev libopencv-dev libsdl2-dev libsystemd-dev libudev-dev libusb-1.0-0-dev libuvc-dev libv4l-dev libvulkan-dev libwayland-dev libx11-dev libx11-xcb-dev libxcb-randr0-dev libxrandr-dev libxxf86vm-dev ninja-build pandoc patch pkg-config python3 reprepro unzip wget' # Make Arch rolling image arch:rolling:container_prep: @@ -109,7 +109,7 @@ arch:rolling:container_prep: changes: - .gitlab-ci/**/* variables: - FDO_DISTRIBUTION_PACKAGES: 'check clang cmake diffutils doxygen eigen ffmpeg gcc git glfw-x11 glslang graphviz gtk3 hidapi libusb libxrandr mesa ninja opencv patch pkgconfig python3 qt5-base v4l-utils vulkan-headers vulkan-icd-loader' + FDO_DISTRIBUTION_PACKAGES: 'bluez-libs check clang cmake diffutils doxygen eigen ffmpeg gcc git glfw-x11 glslang graphviz gtk3 hidapi libusb libxrandr mesa ninja opencv patch pkgconfig python3 qt5-base v4l-utils vulkan-headers vulkan-icd-loader' ### # Container usage base jobs diff --git a/.gitlab-ci/config.yml b/.gitlab-ci/config.yml index 76202cdce..fc40a2d50 100644 --- a/.gitlab-ci/config.yml +++ b/.gitlab-ci/config.yml @@ -47,6 +47,7 @@ fdo_ci_templates_sha: 34039cd573a2df832d465bc9e4c5f543571f5241 libgstreamer-plugins-base1.0-dev: libsystemd-dev: libbsd-dev: + libbluetooth-dev: # Only used for building packages devscripts: debhelper: @@ -68,7 +69,7 @@ distributions: # This image does some extra work. - codename: bullseye script: i386_and_proclamation_container_prep.sh - tag: "2022-04-22.0" + tag: "2022-07-25.0" deb_version_suffix: bpo11 packages: <<: *default_debian_packages @@ -115,7 +116,7 @@ distributions: distro_version: bullseye repo_suffix: ndk script: android_container_prep.sh - tag: "2022-06-27.0" + tag: "2022-07-25.0" # This must match ext.sharedTargetSdk in build.gradle android_compile_sdk: 31 # This must match buildscript.ext.buildToolsVersion in build.gradle @@ -170,7 +171,7 @@ distributions: # LTS - codename: focal distro_version: "20.04" - tag: "2022-07-24.0" + tag: "2022-07-25.0" deb_version_suffix: ubuntu2004 packages: <<: *default_debian_packages @@ -183,7 +184,7 @@ distributions: - name: arch images: - codename: rolling - tag: "2022-04-22.0" + tag: "2022-07-25.0" packages: git: gcc: @@ -211,6 +212,7 @@ distributions: ffmpeg: v4l-utils: qt5-base: + bluez-libs: build_jobs: - name: "arch:cmake" diff --git a/CMakeLists.txt b/CMakeLists.txt index 840c49159..a286ab357 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,7 @@ endif() find_package(Eigen3 3 REQUIRED) find_package(Vulkan MODULE) find_package(HIDAPI MODULE) +find_package(bluetooth MODULE) find_package(OpenHMD MODULE) find_package( OpenCV @@ -262,6 +263,7 @@ option_with_deps(XRT_INSTALL_SYSTEMD_UNIT_FILES "Install user unit files for sys option_with_deps(XRT_INSTALL_ABSOLUTE_SYSTEMD_UNIT_FILES "Use an absolute path to monado-system in installed user unit files for systemd socket activation" DEPENDS XRT_HAVE_SYSTEMD) # Driver deps to use (sorted, though there are some internal dependencies) +option_with_deps(XRT_HAVE_BLUETOOTH "Enable Bluetooth (legacy, non-ble)" DEPENDS BLUETOOTH_FOUND) option_with_deps(XRT_HAVE_FFMPEG "Enable ffmpeg testing video driver" DEPENDS FFMPEG_FOUND) option_with_deps(XRT_HAVE_GST "Enable gstreamer" DEPENDS GST_FOUND) option_with_deps(XRT_HAVE_HIDAPI "Enable libhidapi (used for PSVR)" DEPENDS HIDAPI_FOUND) @@ -443,6 +445,7 @@ endif() message(STATUS "#####----- Config -----#####") message(STATUS "# GIT_DESC: ${GIT_DESC}") message(STATUS "#") +message(STATUS "# BLUETOOTH: ${XRT_HAVE_BLUETOOTH}") message(STATUS "# BASALT: ${XRT_HAVE_BASALT_SLAM}") message(STATUS "# D3D11: ${XRT_HAVE_D3D11}") message(STATUS "# DBUS: ${XRT_HAVE_DBUS}") diff --git a/cmake/Findbluetooth.cmake b/cmake/Findbluetooth.cmake new file mode 100644 index 000000000..ce89a5695 --- /dev/null +++ b/cmake/Findbluetooth.cmake @@ -0,0 +1,66 @@ +# Copyright 2022, Collabora, Ltd. +# SPDX-License-Identifier: BSL-1.0 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +# +# Original Author: +# 2022 Daniel Willmott + +#.rst: +# Findbluetooth +# --------------- +# +# Find the bluetooth library +# +# Targets +# ^^^^^^^ +# +# If successful, the following import target is created. +# +# ``bluetooth::bluetooth`` +# +# Cache variables +# ^^^^^^^^^^^^^^^ +# +# The following cache variable may also be set to assist/control the operation of this module: +# +# ``BLUETOOTH_ROOT_DIR`` +# The root to search for bluetooth + +set(bluetooth_ROOT_DIR + "${bluetooth_ROOT_DIR}" + CACHE + PATH + "Directory to search for the BlueZ bluetooth library") + +find_package(PkgConfig) +pkg_check_modules(PC_BLUETOOTH QUIET bluetooth bluez) + +find_path(bluetooth_INCLUDE_DIR + NAMES bluetooth/bluetooth.h + PATHS ${bluetooth_ROOT_DIR} + HINTS ${PC_BLUETOOTH_INCLUDE_DIRS}) +find_library( + bluetooth_LIBRARY + NAMES bluetooth libbluetooth + PATHS ${bluetooth_ROOT_DIR} + HINTS ${PC_BLUETOOTH_LIBDIR}) + + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(bluetooth + REQUIRED_VARS bluetooth_LIBRARY bluetooth_INCLUDE_DIR) + +if (bluetooth_FOUND) + set(bluetooth_INCLUDE_DIRS ${bluetooth_INCLUDE_DIR}) + set(bluetooth_LIBRARIES ${bluetooth_LIBRARY}) + + if (NOT TARGET bluetooth::bluetooth) + add_library(bluetooth::bluetooth UNKNOWN IMPORTED) + set_target_properties(bluetooth::bluetooth PROPERTIES + IMPORTED_LOCATION "${bluetooth_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${bluetooth_INCLUDE_DIR}") + endif () +endif() +mark_as_advanced(bluetooth_INCLUDE_DIR bluetooth_LIBRARY)