4 # Finds the Bluetooth library
6 # This will define the following target:
8 # ${APP_NAME_LC}::Bluetooth - The Bluetooth library
10 if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
11 find_package(PkgConfig)
13 pkg_check_modules(PC_BLUETOOTH bluez bluetooth QUIET)
16 find_path(BLUETOOTH_INCLUDE_DIR NAMES bluetooth/bluetooth.h
17 HINTS ${PC_BLUETOOTH_INCLUDEDIR})
18 find_library(BLUETOOTH_LIBRARY NAMES bluetooth libbluetooth
19 HINTS ${PC_BLUETOOTH_LIBDIR})
21 set(BLUETOOTH_VERSION ${PC_BLUETOOTH_VERSION})
23 include(FindPackageHandleStandardArgs)
24 find_package_handle_standard_args(Bluetooth
25 REQUIRED_VARS BLUETOOTH_LIBRARY BLUETOOTH_INCLUDE_DIR
26 VERSION_VAR BLUETOOTH_VERSION)
29 add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED)
30 set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
31 IMPORTED_LOCATION "${BLUETOOTH_LIBRARY}"
32 INTERFACE_INCLUDE_DIRECTORIES "${BLUETOOTH_INCLUDE_DIR}"
33 INTERFACE_COMPILE_DEFINITIONS HAVE_LIBBLUETOOTH)