cmake: allow hidapi to use libusb on Windows

When using SDL_HIDAPI_LIBUSB_SHARED=ON, extract the dll file name
from the import library.
This commit is contained in:
Anonymous Maarten
2023-11-29 22:08:09 +01:00
committed by Sam Lantinga
parent 3bc27d3856
commit 7341d5f361
3 changed files with 197 additions and 5 deletions

View File

@@ -1053,10 +1053,10 @@ macro(CheckHIDAPI)
cmake_pop_check_state()
if(HAVE_LIBUSB_H)
set(HAVE_LIBUSB TRUE)
FindLibraryAndSONAME("usb-1.0" LIBDIRS ${PC_LIBUSB_LIBRARY_DIRS})
if(SDL_HIDAPI_LIBUSB_SHARED AND USB_1.0_LIB_SONAME)
target_get_dynamic_library(dynamic_libusb LibUSB::LibUSB)
if(SDL_HIDAPI_LIBUSB_SHARED AND dynamic_libusb)
set(HAVE_HIDAPI_LIBUSB_SHARED ON)
set(SDL_LIBUSB_DYNAMIC "\"${USB_1.0_LIB_SONAME}\"")
set(SDL_LIBUSB_DYNAMIC "\"${dynamic_libusb}\"")
sdl_link_dependency(hidapi INCLUDES $<TARGET_PROPERTY:LibUSB::LibUSB,INTERFACE_INCLUDE_DIRECTORIES>)
else()
sdl_link_dependency(hidapi LIBS LibUSB::LibUSB PKG_CONFIG_SPECS "${LibUSB_PKG_CONFIG_SPEC}" CMAKE_MODULE LibUSB)