mirror of https://github.com/libsdl-org/SDL
cmake: add SDL_HIDAPI_LIBUSB_SHARED option + test on ci
This commit is contained in:
parent
371cc2d173
commit
c2f388fd88
|
@ -52,7 +52,7 @@ jobs:
|
|||
sudo apt-get update
|
||||
sudo apt-get install build-essential git \
|
||||
pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
|
||||
libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
|
||||
libaudio-dev libjack-dev libsndio-dev libusb-1.0-0-dev libx11-dev libxext-dev \
|
||||
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
|
||||
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
|
||||
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
|
||||
|
|
|
@ -342,6 +342,7 @@ option_string(SDL_BACKGROUNDING_SIGNAL "number to use for magic backgrounding si
|
|||
option_string(SDL_FOREGROUNDING_SIGNAL "number to use for magic foregrounding signal or 'OFF'" OFF)
|
||||
dep_option(SDL_HIDAPI "Enable the HIDAPI subsystem" ON "NOT VISIONOS" OFF)
|
||||
dep_option(SDL_HIDAPI_LIBUSB "Use libusb for low level joystick drivers" ON SDL_HIDAPI_LIBUSB_AVAILABLE OFF)
|
||||
dep_option(SDL_HIDAPI_LIBUSB_SHARED "Dynamically load libusb support" ON SDL_HIDAPI_LIBUSB OFF)
|
||||
dep_option(SDL_HIDAPI_JOYSTICK "Use HIDAPI for low level joystick drivers" ON SDL_HIDAPI OFF)
|
||||
dep_option(SDL_VIRTUAL_JOYSTICK "Enable the virtual-joystick driver" ON SDL_HIDAPI OFF)
|
||||
set_option(SDL_LIBUDEV "Enable libudev support" ON)
|
||||
|
|
|
@ -1019,8 +1019,8 @@ endmacro()
|
|||
|
||||
# Check for HIDAPI support
|
||||
macro(CheckHIDAPI)
|
||||
set(HAVE_HIDAPI TRUE)
|
||||
if(SDL_HIDAPI)
|
||||
set(HAVE_HIDAPI ON)
|
||||
if(SDL_HIDAPI_LIBUSB)
|
||||
set(HAVE_LIBUSB FALSE)
|
||||
|
||||
|
@ -1033,21 +1033,16 @@ macro(CheckHIDAPI)
|
|||
cmake_pop_check_state()
|
||||
if(HAVE_LIBUSB_H)
|
||||
set(HAVE_LIBUSB TRUE)
|
||||
if(HIDAPI_ONLY_LIBUSB)
|
||||
sdl_link_dependency(hidapi LIBS PkgConfig::PC_LIBUSB PKG_CONFIG_PREFIX PC_LIBUSB PKG_CONFIG_SPECS ${LibUSB_PKG_CONFIG_SPEC})
|
||||
else()
|
||||
# libusb is loaded dynamically, so don't add link to it
|
||||
FindLibraryAndSONAME("usb-1.0" LIBDIRS ${PC_LIBUSB_LIBRARY_DIRS})
|
||||
if(USB_1.0_LIB)
|
||||
set(SDL_LIBUSB_DYNAMIC "\"${USB_1.0_LIB_SONAME}\"")
|
||||
endif()
|
||||
FindLibraryAndSONAME("usb-1.0" LIBDIRS ${PC_LIBUSB_LIBRARY_DIRS})
|
||||
if(SDL_HIDAPI_LIBUSB_SHARED AND USB_1.0_LIB_SONAME)
|
||||
set(HAVE_HIDAPI_LIBUSB_SHARED ON)
|
||||
set(SDL_LIBUSB_DYNAMIC "\"${USB_1.0_LIB_SONAME}\"")
|
||||
sdl_link_dependency(hidapi INCLUDES $<TARGET_PROPERTY:PkgConfig::PC_LIBUSB,INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
else()
|
||||
sdl_link_dependency(hidapi LIBS PkgConfig::PC_LIBUSB PKG_CONFIG_PREFIX PC_LIBUSB PKG_CONFIG_SPECS ${LibUSB_PKG_CONFIG_SPEC})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(HIDAPI_ONLY_LIBUSB AND NOT HAVE_LIBUSB)
|
||||
set(HAVE_HIDAPI FALSE)
|
||||
endif()
|
||||
set(HAVE_HIDAPI_LIBUSB ${HAVE_LIBUSB})
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Reference in New Issue