cmake: when there are alternatives, don't use libusb by default
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7490b1e..13fbe81 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 07d472a..198a7e9 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)