summaryrefslogtreecommitdiffstats
path: root/externals/find-modules
diff options
context:
space:
mode:
Diffstat (limited to 'externals/find-modules')
-rw-r--r--externals/find-modules/FindLibUSB.cmake44
-rw-r--r--externals/find-modules/Findlibusb.cmake18
2 files changed, 18 insertions, 44 deletions
diff --git a/externals/find-modules/FindLibUSB.cmake b/externals/find-modules/FindLibUSB.cmake
deleted file mode 100644
index 617daf9a5..000000000
--- a/externals/find-modules/FindLibUSB.cmake
+++ /dev/null
@@ -1,44 +0,0 @@
-# SPDX-FileCopyrightText: 2009 Michal Cihar <michal@cihar.com>
-# SPDX-License-Identifier: GPL-2.0-or-later
-
-# - Find libusb-1.0 library
-# This module defines
-# LIBUSB_INCLUDE_DIR, where to find bluetooth.h
-# LIBUSB_LIBRARIES, the libraries needed to use libusb-1.0.
-# LIBUSB_FOUND, If false, do not try to use libusb-1.0.
-#
-# vim: expandtab sw=4 ts=4 sts=4:
-
-if(ANDROID)
- set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found")
- message(STATUS "libusb-1.0 not found.")
-elseif (NOT LIBUSB_FOUND)
- pkg_check_modules (LIBUSB_PKG libusb-1.0)
-
- find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h
- PATHS
- ${LIBUSB_PKG_INCLUDE_DIRS}
- /usr/include/libusb-1.0
- /usr/include
- /usr/local/include/libusb-1.0
- /usr/local/include
- )
-
- find_library(LIBUSB_LIBRARIES NAMES usb-1.0 usb
- PATHS
- ${LIBUSB_PKG_LIBRARY_DIRS}
- /usr/lib
- /usr/local/lib
- )
-
- if(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
- set(LIBUSB_FOUND TRUE CACHE INTERNAL "libusb-1.0 found")
- message(STATUS "Found libusb-1.0: ${LIBUSB_INCLUDE_DIR}, ${LIBUSB_LIBRARIES}")
- else(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
- set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found")
- message(STATUS "libusb-1.0 not found.")
- endif(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
-
- mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES)
-endif ()
-
diff --git a/externals/find-modules/Findlibusb.cmake b/externals/find-modules/Findlibusb.cmake
new file mode 100644
index 000000000..66f61001c
--- /dev/null
+++ b/externals/find-modules/Findlibusb.cmake
@@ -0,0 +1,18 @@
+# SPDX-FileCopyrightText: 2022 Alexandre Bouvier <contact@amb.tf>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+find_package(PkgConfig QUIET)
+if (PKG_CONFIG_FOUND)
+ pkg_search_module(LIBUSB QUIET IMPORTED_TARGET libusb-1.0)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(libusb
+ REQUIRED_VARS LIBUSB_LINK_LIBRARIES
+ VERSION_VAR LIBUSB_VERSION
+)
+
+if (libusb_FOUND AND NOT TARGET libusb::usb)
+ add_library(libusb::usb ALIAS PkgConfig::LIBUSB)
+endif()