Skip to content

Commit

Permalink
CMake: Find libusb include dir using pkg-config
Browse files Browse the repository at this point in the history
Prior to this, only the library was discovered using pkg-config, while
the header was searched manually. This caused troubles on the CI when
building for OSX, as it would succeed to find the library but not the
header file.

Now, the manual search is now performed only when pkg-config cannot
locate a libusb package; which is what was already done for the library
file itself.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed Jul 3, 2023
1 parent ad199c6 commit 28e1b30
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,12 @@ if (WITH_USB_BACKEND)
if (NOT LIBUSB_FOUND)
#Handle FreeBSD libusb and Linux libusb-1.0 libraries
find_library(LIBUSB_LIBRARIES NAMES usb-1.0 usb)
find_path(LIBUSB_INCLUDE_DIR libusb.h PATH_SUFFIXES libusb-1.0)
else()
set(LIBUSB_LIBRARIES ${LIBUSB_LINK_LIBRARIES})
set(LIBUSB_INCLUDE_DIR ${LIBUSB_INCLUDE_DIRS})
endif()
endif()
find_path(LIBUSB_INCLUDE_DIR libusb.h PATH_SUFFIXES libusb-1.0)
if (NOT LIBUSB_LIBRARIES OR NOT LIBUSB_INCLUDE_DIR)
message(SEND_ERROR "Unable to find libusb-1.0 dependency.\n"
"If you want to disable the USB backend, set WITH_USB_BACKEND=OFF.")
Expand Down

0 comments on commit 28e1b30

Please sign in to comment.