From a4e6f3ca9d48c32bb674f9b5142a5b3d401496c0 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 26 Jul 2022 02:41:43 +0200 Subject: [PATCH] cmake: when there are alternatives, don't use libusb by default --- CMakeLists.txt | 12 ++++++++++-- cmake/sdlchecks.cmake | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7490b1e63..13fbe81b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -499,8 +499,10 @@ dep_option(SDL_KMSDRM_SHARED "Dynamically load KMS DRM support" ON "SDL_KM set_option(SDL_OFFSCREEN "Use offscreen video driver" OFF) option_string(SDL_BACKGROUNDING_SIGNAL "number to use for magic backgrounding signal or 'OFF'" OFF) option_string(SDL_FOREGROUNDING_SIGNAL "number to use for magic foregrounding signal or 'OFF'" OFF) -set_option(SDL_HIDAPI_JOYSTICK "Use HIDAPI for low level joystick drivers" ON) -set_option(SDL_VIRTUAL_JOYSTICK "Enable the virtual-joystick driver" ON) +set_option(SDL_HIDAPI "Enable the HIDAPI subsystem" ON) +dep_option(SDL_HIDAPI_LIBUSB "Use libusb for low level joystick drivers" OFF SDL_HIDAPI 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_ASAN "Use AddressSanitizer to detect memory errors" OFF) set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library") @@ -513,6 +515,12 @@ set_option(SDL_INSTALL_TESTS "Install test-cases" OFF) set(HAVE_STATIC_PIC "${SDL_STATIC_PIC}") +if(HIDAPI_ONLY_LIBUSB) + set(SDL_HIDAPI_LIBUSB ON CACHE BOOL "" FORCE) +elseif(HIDAPI_SKIP_LIBUSB) + set(SDL_HIDAPI_LIBUSB OFF CACHE BOOL "" FORCE) +endif() + if(VITA) set_option(VIDEO_VITA_PIB "Build with PSVita piglet gles2 support" OFF) set_option(VIDEO_VITA_PVR "Build with PSVita PVR gles/gles2 support" OFF) diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake index 07d472a7e..198a7e9a1 100644 --- a/cmake/sdlchecks.cmake +++ b/cmake/sdlchecks.cmake @@ -1176,10 +1176,10 @@ endmacro() # Check for HIDAPI support macro(CheckHIDAPI) set(HAVE_HIDAPI TRUE) - if(NOT HIDAPI_SKIP_LIBUSB) + if(SDL_HIDAPI_LIBUSB) set(HAVE_LIBUSB FALSE) pkg_check_modules(LIBUSB libusb-1.0) - if (LIBUSB_FOUND) + if(LIBUSB_FOUND) check_include_file(libusb.h HAVE_LIBUSB_H ${LIBUSB_CFLAGS}) if(HAVE_LIBUSB_H) set(HAVE_LIBUSB TRUE)