mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-05-06 05:16:24 -05:00
LibUSB: Improve library detection
Our FindLibUSB.cmake was previously entirely unused unless SDL was being built from Externals, we now rely on it again. It will use PkgConfig if applicable or fall back to looking around on the system, and more importantly it will always create an imported target.
This commit is contained in:
parent
184c6ee068
commit
3cea68c2e5
|
|
@ -11,8 +11,15 @@
|
|||
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)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(TARGET LibUSB::LibUSB)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT LIBUSB_FOUND)
|
||||
pkg_check_modules(LIBUSB_PKG libusb-1.0)
|
||||
|
||||
find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||
PATHS
|
||||
|
|
@ -30,21 +37,19 @@ elseif (NOT LIBUSB_FOUND)
|
|||
/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 ()
|
||||
if(LIBUSB_FOUND AND NOT TARGET LibUSB::LibUSB)
|
||||
endif()
|
||||
|
||||
|
||||
if(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
|
||||
add_library(LibUSB::LibUSB UNKNOWN IMPORTED)
|
||||
set_target_properties(LibUSB::LibUSB PROPERTIES
|
||||
IMPORTED_LOCATION "${LIBUSB_LIBRARIES}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LIBUSB_INCLUDE_DIR}"
|
||||
)
|
||||
set(LIBUSB_FOUND TRUE CACHE INTERNAL "libusb-1.0 found")
|
||||
message(STATUS "Found libusb-1.0: ${LIBUSB_INCLUDE_DIR}, ${LIBUSB_LIBRARIES}")
|
||||
else()
|
||||
set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found")
|
||||
message(STATUS "libusb-1.0 not found.")
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -708,9 +708,7 @@ if(ENABLE_CUBEB)
|
|||
endif()
|
||||
|
||||
if(NOT ANDROID)
|
||||
dolphin_find_optional_system_library_pkgconfig(
|
||||
LibUSB libusb-1.0 LibUSB::LibUSB Externals/libusb
|
||||
)
|
||||
dolphin_find_optional_system_library(LibUSB Externals/libusb)
|
||||
add_definitions(-D__LIBUSB__)
|
||||
endif()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user