Merge pull request #23092 from webosbrew/feature/webOS
[xbmc.git] / cmake / modules / FindBluetooth.cmake
blob7ca99bb32e75967f09f898cbc2566b4e0aca8cad
1 #.rst:
2 # FindBluetooth
3 # ---------
4 # Finds the Bluetooth library
6 # This will define the following variables::
8 # BLUETOOTH_FOUND - system has Bluetooth
9 # BLUETOOTH_INCLUDE_DIRS - the Bluetooth include directory
10 # BLUETOOTH_LIBRARIES - the Bluetooth libraries
12 # and the following imported targets::
14 #   Bluetooth::Bluetooth   - The Bluetooth library
16 if(PKG_CONFIG_FOUND)
17   pkg_check_modules(PC_BLUETOOTH bluez bluetooth QUIET)
18 endif()
20 find_path(BLUETOOTH_INCLUDE_DIR NAMES bluetooth/bluetooth.h
21                                 PATHS ${PC_BLUETOOTH_INCLUDEDIR})
22 find_library(BLUETOOTH_LIBRARY NAMES bluetooth libbluetooth
23                                PATHS ${PC_BLUETOOTH_LIBDIR})
25 set(BLUETOOTH_VERSION ${PC_BLUETOOTH_VERSION})
27 include(FindPackageHandleStandardArgs)
28 find_package_handle_standard_args(Bluetooth
29                                   REQUIRED_VARS BLUETOOTH_LIBRARY BLUETOOTH_INCLUDE_DIR
30                                   VERSION_VAR BLUETOOTH_VERSION)
32 if(BLUETOOTH_FOUND)
33   set(BLUETOOTH_INCLUDE_DIRS ${BLUETOOTH_INCLUDE_DIR})
34   set(BLUETOOTH_LIBRARIES ${BLUETOOTH_LIBRARY})
36   if(NOT TARGET Bluetooth::Bluetooth)
37     add_library(Bluetooth::Bluetooth UNKNOWN IMPORTED)
38     set_target_properties(Bluetooth::Bluetooth PROPERTIES
39                                                IMPORTED_LOCATION "${BLUETOOTH_LIBRARY}"
40                                                INTERFACE_INCLUDE_DIRECTORIES "${BLUETOOTH_INCLUDE_DIR}")
41   endif()
42 endif()
44 mark_as_advanced(BLUETOOTH_INCLUDE_DIR BLUETOOTH_LIBRARY)