diff options
author | fuzzard <fuzzard@kodi.tv> | 2023-09-05 16:33:37 +1000 |
---|---|---|
committer | fuzzard <fuzzard@kodi.tv> | 2023-09-06 09:05:29 +1000 |
commit | 9f075a723900aa2d9be1e81e40b4503829d4d2b0 (patch) | |
tree | fca90676d7a2526588f5de5d846e362cd699771f | |
parent | 18e73c6e8c6a887882ff51784383f871f9981627 (diff) |
[cmake] FindBluetooth migrate fully to TARGET usage
-rw-r--r-- | cmake/modules/FindBluetooth.cmake | 48 | ||||
-rw-r--r-- | cmake/scripts/linux/ExtraTargets.cmake | 2 | ||||
-rw-r--r-- | cmake/scripts/linux/Install.cmake | 2 | ||||
-rw-r--r-- | xbmc/network/CMakeLists.txt | 3 |
4 files changed, 23 insertions, 32 deletions
diff --git a/cmake/modules/FindBluetooth.cmake b/cmake/modules/FindBluetooth.cmake index 7ca99bb32e..0ac691324e 100644 --- a/cmake/modules/FindBluetooth.cmake +++ b/cmake/modules/FindBluetooth.cmake @@ -3,42 +3,36 @@ # --------- # Finds the Bluetooth library # -# This will define the following variables:: -# -# BLUETOOTH_FOUND - system has Bluetooth -# BLUETOOTH_INCLUDE_DIRS - the Bluetooth include directory -# BLUETOOTH_LIBRARIES - the Bluetooth libraries -# -# and the following imported targets:: +# This will define the following target: # # Bluetooth::Bluetooth - The Bluetooth library -if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_BLUETOOTH bluez bluetooth QUIET) -endif() - -find_path(BLUETOOTH_INCLUDE_DIR NAMES bluetooth/bluetooth.h - PATHS ${PC_BLUETOOTH_INCLUDEDIR}) -find_library(BLUETOOTH_LIBRARY NAMES bluetooth libbluetooth - PATHS ${PC_BLUETOOTH_LIBDIR}) +if(NOT TARGET Bluetooth::Bluetooth) + find_package(PkgConfig) + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_BLUETOOTH bluez bluetooth QUIET) + endif() -set(BLUETOOTH_VERSION ${PC_BLUETOOTH_VERSION}) + find_path(BLUETOOTH_INCLUDE_DIR NAMES bluetooth/bluetooth.h + PATHS ${PC_BLUETOOTH_INCLUDEDIR} + NO_CACHE) + find_library(BLUETOOTH_LIBRARY NAMES bluetooth libbluetooth + PATHS ${PC_BLUETOOTH_LIBDIR} + NO_CACHE) -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Bluetooth - REQUIRED_VARS BLUETOOTH_LIBRARY BLUETOOTH_INCLUDE_DIR - VERSION_VAR BLUETOOTH_VERSION) + set(BLUETOOTH_VERSION ${PC_BLUETOOTH_VERSION}) -if(BLUETOOTH_FOUND) - set(BLUETOOTH_INCLUDE_DIRS ${BLUETOOTH_INCLUDE_DIR}) - set(BLUETOOTH_LIBRARIES ${BLUETOOTH_LIBRARY}) + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Bluetooth + REQUIRED_VARS BLUETOOTH_LIBRARY BLUETOOTH_INCLUDE_DIR + VERSION_VAR BLUETOOTH_VERSION) - if(NOT TARGET Bluetooth::Bluetooth) + if(BLUETOOTH_FOUND) add_library(Bluetooth::Bluetooth UNKNOWN IMPORTED) set_target_properties(Bluetooth::Bluetooth PROPERTIES IMPORTED_LOCATION "${BLUETOOTH_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${BLUETOOTH_INCLUDE_DIR}") + INTERFACE_INCLUDE_DIRECTORIES "${BLUETOOTH_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS HAVE_LIBBLUETOOTH=1) + set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP Bluetooth::Bluetooth) endif() endif() - -mark_as_advanced(BLUETOOTH_INCLUDE_DIR BLUETOOTH_LIBRARY) diff --git a/cmake/scripts/linux/ExtraTargets.cmake b/cmake/scripts/linux/ExtraTargets.cmake index 62c6a400b1..548083a5d4 100644 --- a/cmake/scripts/linux/ExtraTargets.cmake +++ b/cmake/scripts/linux/ExtraTargets.cmake @@ -7,7 +7,7 @@ if(X_FOUND AND XRANDR_FOUND) endif() # WiiRemote -if(ENABLE_EVENTCLIENTS AND BLUETOOTH_FOUND) +if(ENABLE_EVENTCLIENTS AND TARGET Bluetooth::Bluetooth) find_package(CWiid QUIET) find_package(GLU QUIET) if(CWIID_FOUND AND GLU_FOUND) diff --git a/cmake/scripts/linux/Install.cmake b/cmake/scripts/linux/Install.cmake index af06021b9f..f15026e3b5 100644 --- a/cmake/scripts/linux/Install.cmake +++ b/cmake/scripts/linux/Install.cmake @@ -280,7 +280,7 @@ if(ENABLE_EVENTCLIENTS) DESTINATION ${bindir} COMPONENT kodi-eventclients-ps3) - if(BLUETOOTH_FOUND AND CWIID_FOUND AND GLU_FOUND) + if(TARGET Bluetooth::Bluetooth AND CWIID_FOUND AND GLU_FOUND) # Install kodi-eventclients-wiiremote install(PROGRAMS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/WiiRemote/${APP_NAME_LC}-wiiremote DESTINATION ${bindir} diff --git a/xbmc/network/CMakeLists.txt b/xbmc/network/CMakeLists.txt index 50757a6c89..147af290b6 100644 --- a/xbmc/network/CMakeLists.txt +++ b/xbmc/network/CMakeLists.txt @@ -51,9 +51,6 @@ if(MICROHTTPD_FOUND) endif() core_add_library(network) -if(BLUETOOTH_FOUND) - target_compile_definitions(${CORE_LIBRARY} PRIVATE -DHAVE_LIBBLUETOOTH=1) -endif() if(ENABLE_STATIC_LIBS AND ENABLE_UPNP) target_link_libraries(${CORE_LIBRARY} PRIVATE upnp) |