From 29b3fcfb1bc834d0187a8114debdcbbf8381cd61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Vanda=C3=ABle?= Date: Fri, 2 Jan 2026 14:40:24 +0100 Subject: [PATCH] SDL: Use bundled LibUSB when desirable, update to bc68c1c Previously, SDL would `find_package(libusb)` which would actually overwrite the user preference in the case where both USE_SYSTEM_LIBUSB and USE_SYSTEM_SDL were OFF. This coincidentally also allows SDL to use libusb on Windows. SDL is being updated slightly since commits 4a29b6a and bc68c1c are needed to fix using a static libusb and hidapi alongside SDL. --- CMakeLists.txt | 8 ++++---- Externals/SDL/CMakeLists.txt | 5 +++++ Externals/SDL/SDL | 2 +- Externals/libusb/CMakeLists.txt | 13 ++++++++++++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de9446014d..38135abda9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -582,10 +582,6 @@ if(UNIX) add_definitions(-DUSE_MEMORYWATCHER=1) endif() -if(ENABLE_SDL) - dolphin_find_optional_system_library(SDL3 Externals/SDL 3.2.0) -endif() - if(ENABLE_ANALYTICS) message(STATUS "Enabling analytics collection (subject to end-user opt-in)") add_definitions(-DUSE_ANALYTICS=1) @@ -712,6 +708,10 @@ if(NOT ANDROID) add_definitions(-D__LIBUSB__) endif() +if(ENABLE_SDL) + dolphin_find_optional_system_library(SDL3 Externals/SDL 3.2.0) +endif() + dolphin_find_optional_system_library(SFML Externals/SFML 3.0 COMPONENTS Network System) if(USE_UPNP) diff --git a/Externals/SDL/CMakeLists.txt b/Externals/SDL/CMakeLists.txt index 0316360241..6bdd630101 100644 --- a/Externals/SDL/CMakeLists.txt +++ b/Externals/SDL/CMakeLists.txt @@ -20,6 +20,11 @@ if(CCACHE_BIN) set(CCACHE_BINARY ${CCACHE_BIN}) endif() +if(LibUSB_TYPE STREQUAL Bundled) + set(LibUSB_FOUND TRUE) + set(SDL_HIDAPI_LIBUSB_SHARED OFF) +endif() + add_subdirectory(SDL) if (TARGET SDL3) diff --git a/Externals/SDL/SDL b/Externals/SDL/SDL index a962f40bbb..bc68c1c920 160000 --- a/Externals/SDL/SDL +++ b/Externals/SDL/SDL @@ -1 +1 @@ -Subproject commit a962f40bbba175e9716557a25d5d7965f134a3d3 +Subproject commit bc68c1c920f7ae87f2ac1ab03a44b2252ad1864e diff --git a/Externals/libusb/CMakeLists.txt b/Externals/libusb/CMakeLists.txt index dafb563f72..ffd6d42781 100644 --- a/Externals/libusb/CMakeLists.txt +++ b/Externals/libusb/CMakeLists.txt @@ -125,4 +125,15 @@ check_include_files(sys/timerfd.h HAVE_TIMERFD) check_include_files(unistd.h HAVE_UNISTD_H) configure_file(config.h.in config.h) -add_library(LibUSB::LibUSB ALIAS usb) + +# We don't create an ALIAS here so that dependencies (SDL) that try_compile libusb +# don't fail due to LibUSB::LibUSB being an alias target +add_library(LibUSB::LibUSB INTERFACE IMPORTED GLOBAL) +target_link_libraries(LibUSB::LibUSB + INTERFACE + usb +) +target_include_directories(LibUSB::LibUSB + INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/libusb/libusb +)