Merge pull request #25883 from CrystalP/fix-slowscan
[xbmc.git] / cmake / modules / FindBluetooth.cmake
blob024c51e63b12f5490c9370fae3e74b4f6485b7ce
1 #.rst:
2 # FindBluetooth
3 # ---------
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)
12   if(PKG_CONFIG_FOUND)
13     pkg_check_modules(PC_BLUETOOTH bluez bluetooth QUIET)
14   endif()
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)
28   if(BLUETOOTH_FOUND)
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)
34   endif()
35 endif()