diff options
| author | 2022-12-28 17:26:46 -0500 | |
|---|---|---|
| committer | 2022-12-28 17:26:46 -0500 | |
| commit | be43b62d79cc03f9908ce5036f96a94e9053ba65 (patch) | |
| tree | 0c55f4709eb56914520aa711f5735a96877fda1f | |
| parent | cmake: ignore missing package finders for packages with submodule fallbacks (diff) | |
| download | yuzu-be43b62d79cc03f9908ce5036f96a94e9053ba65.tar.gz yuzu-be43b62d79cc03f9908ce5036f96a94e9053ba65.tar.xz yuzu-be43b62d79cc03f9908ce5036f96a94e9053ba65.zip | |
cmake: make libusb optional
| -rw-r--r-- | CMakeLists.txt | 7 | ||||
| -rw-r--r-- | externals/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/input_common/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | src/input_common/main.cpp | 24 |
4 files changed, 39 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a124db07..ea7829707 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -22,6 +22,8 @@ CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" ON | |||
| 22 | # On Linux system SDL2 is likely to be lacking HIDAPI support which have drawbacks but is needed for SDL motion | 22 | # On Linux system SDL2 is likely to be lacking HIDAPI support which have drawbacks but is needed for SDL motion |
| 23 | CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" ON "ENABLE_SDL2;NOT MSVC" OFF) | 23 | CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" ON "ENABLE_SDL2;NOT MSVC" OFF) |
| 24 | 24 | ||
| 25 | option(ENABLE_LIBUSB "Enable the use of LibUSB" ON) | ||
| 26 | |||
| 25 | option(ENABLE_OPENGL "Enable OpenGL" ON) | 27 | option(ENABLE_OPENGL "Enable OpenGL" ON) |
| 26 | mark_as_advanced(FORCE ENABLE_OPENGL) | 28 | mark_as_advanced(FORCE ENABLE_OPENGL) |
| 27 | option(ENABLE_QT "Enable the Qt frontend" ON) | 29 | option(ENABLE_QT "Enable the Qt frontend" ON) |
| @@ -206,7 +208,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) | |||
| 206 | find_package(enet 1.3) | 208 | find_package(enet 1.3) |
| 207 | find_package(fmt 9 REQUIRED) | 209 | find_package(fmt 9 REQUIRED) |
| 208 | find_package(inih) | 210 | find_package(inih) |
| 209 | find_package(libusb 1.0.24) | ||
| 210 | find_package(lz4 REQUIRED) | 211 | find_package(lz4 REQUIRED) |
| 211 | find_package(nlohmann_json 3.8 REQUIRED) | 212 | find_package(nlohmann_json 3.8 REQUIRED) |
| 212 | find_package(Opus 1.3) | 213 | find_package(Opus 1.3) |
| @@ -214,6 +215,10 @@ find_package(Vulkan 1.3.238) | |||
| 214 | find_package(ZLIB 1.2 REQUIRED) | 215 | find_package(ZLIB 1.2 REQUIRED) |
| 215 | find_package(zstd 1.5 REQUIRED) | 216 | find_package(zstd 1.5 REQUIRED) |
| 216 | 217 | ||
| 218 | if (ENABLE_LIBUSB) | ||
| 219 | find_package(libusb 1.0.24) | ||
| 220 | endif() | ||
| 221 | |||
| 217 | if (ARCHITECTURE_x86 OR ARCHITECTURE_x86_64) | 222 | if (ARCHITECTURE_x86 OR ARCHITECTURE_x86_64) |
| 218 | find_package(xbyak 6 QUIET) | 223 | find_package(xbyak 6 QUIET) |
| 219 | endif() | 224 | endif() |
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 4ffafd18c..a83812ebb 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt | |||
| @@ -45,7 +45,7 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12" AND CMAKE_CXX_COMPILER | |||
| 45 | endif() | 45 | endif() |
| 46 | 46 | ||
| 47 | # libusb | 47 | # libusb |
| 48 | if (NOT TARGET libusb::usb) | 48 | if (ENABLE_LIBUSB AND NOT TARGET libusb::usb) |
| 49 | add_subdirectory(libusb EXCLUDE_FROM_ALL) | 49 | add_subdirectory(libusb EXCLUDE_FROM_ALL) |
| 50 | endif() | 50 | endif() |
| 51 | 51 | ||
diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index f24c89b04..cef2c4d52 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt | |||
| @@ -4,14 +4,10 @@ | |||
| 4 | add_library(input_common STATIC | 4 | add_library(input_common STATIC |
| 5 | drivers/camera.cpp | 5 | drivers/camera.cpp |
| 6 | drivers/camera.h | 6 | drivers/camera.h |
| 7 | drivers/gc_adapter.cpp | ||
| 8 | drivers/gc_adapter.h | ||
| 9 | drivers/keyboard.cpp | 7 | drivers/keyboard.cpp |
| 10 | drivers/keyboard.h | 8 | drivers/keyboard.h |
| 11 | drivers/mouse.cpp | 9 | drivers/mouse.cpp |
| 12 | drivers/mouse.h | 10 | drivers/mouse.h |
| 13 | drivers/sdl_driver.cpp | ||
| 14 | drivers/sdl_driver.h | ||
| 15 | drivers/tas_input.cpp | 11 | drivers/tas_input.cpp |
| 16 | drivers/tas_input.h | 12 | drivers/tas_input.h |
| 17 | drivers/touch_screen.cpp | 13 | drivers/touch_screen.cpp |
| @@ -62,8 +58,17 @@ if (ENABLE_SDL2) | |||
| 62 | target_compile_definitions(input_common PRIVATE HAVE_SDL2) | 58 | target_compile_definitions(input_common PRIVATE HAVE_SDL2) |
| 63 | endif() | 59 | endif() |
| 64 | 60 | ||
| 61 | if (ENABLE_LIBUSB) | ||
| 62 | target_sources(input_common PRIVATE | ||
| 63 | drivers/gc_adapter.cpp | ||
| 64 | drivers/gc_adapter.h | ||
| 65 | ) | ||
| 66 | target_link_libraries(input_common PRIVATE libusb::usb) | ||
| 67 | target_compile_definitions(input_common PRIVATE HAVE_LIBUSB) | ||
| 68 | endif() | ||
| 69 | |||
| 65 | create_target_directory_groups(input_common) | 70 | create_target_directory_groups(input_common) |
| 66 | target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost libusb::usb) | 71 | target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost) |
| 67 | 72 | ||
| 68 | if (YUZU_USE_PRECOMPILED_HEADERS) | 73 | if (YUZU_USE_PRECOMPILED_HEADERS) |
| 69 | target_precompile_headers(input_common PRIVATE precompiled_headers.h) | 74 | target_precompile_headers(input_common PRIVATE precompiled_headers.h) |
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 86deb4c7c..4dc92f482 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | #include "common/input.h" | 5 | #include "common/input.h" |
| 6 | #include "common/param_package.h" | 6 | #include "common/param_package.h" |
| 7 | #include "input_common/drivers/camera.h" | 7 | #include "input_common/drivers/camera.h" |
| 8 | #include "input_common/drivers/gc_adapter.h" | ||
| 9 | #include "input_common/drivers/keyboard.h" | 8 | #include "input_common/drivers/keyboard.h" |
| 10 | #include "input_common/drivers/mouse.h" | 9 | #include "input_common/drivers/mouse.h" |
| 11 | #include "input_common/drivers/tas_input.h" | 10 | #include "input_common/drivers/tas_input.h" |
| @@ -19,6 +18,10 @@ | |||
| 19 | #include "input_common/input_mapping.h" | 18 | #include "input_common/input_mapping.h" |
| 20 | #include "input_common/input_poller.h" | 19 | #include "input_common/input_poller.h" |
| 21 | #include "input_common/main.h" | 20 | #include "input_common/main.h" |
| 21 | |||
| 22 | #ifdef HAVE_LIBUSB | ||
| 23 | #include "input_common/drivers/gc_adapter.h" | ||
| 24 | #endif | ||
| 22 | #ifdef HAVE_SDL2 | 25 | #ifdef HAVE_SDL2 |
| 23 | #include "input_common/drivers/sdl_driver.h" | 26 | #include "input_common/drivers/sdl_driver.h" |
| 24 | #endif | 27 | #endif |
| @@ -45,7 +48,9 @@ struct InputSubsystem::Impl { | |||
| 45 | RegisterEngine("keyboard", keyboard); | 48 | RegisterEngine("keyboard", keyboard); |
| 46 | RegisterEngine("mouse", mouse); | 49 | RegisterEngine("mouse", mouse); |
| 47 | RegisterEngine("touch", touch_screen); | 50 | RegisterEngine("touch", touch_screen); |
| 51 | #ifdef HAVE_LIBUSB | ||
| 48 | RegisterEngine("gcpad", gcadapter); | 52 | RegisterEngine("gcpad", gcadapter); |
| 53 | #endif | ||
| 49 | RegisterEngine("cemuhookudp", udp_client); | 54 | RegisterEngine("cemuhookudp", udp_client); |
| 50 | RegisterEngine("tas", tas_input); | 55 | RegisterEngine("tas", tas_input); |
| 51 | RegisterEngine("camera", camera); | 56 | RegisterEngine("camera", camera); |
| @@ -72,7 +77,9 @@ struct InputSubsystem::Impl { | |||
| 72 | UnregisterEngine(keyboard); | 77 | UnregisterEngine(keyboard); |
| 73 | UnregisterEngine(mouse); | 78 | UnregisterEngine(mouse); |
| 74 | UnregisterEngine(touch_screen); | 79 | UnregisterEngine(touch_screen); |
| 80 | #ifdef HAVE_LIBUSB | ||
| 75 | UnregisterEngine(gcadapter); | 81 | UnregisterEngine(gcadapter); |
| 82 | #endif | ||
| 76 | UnregisterEngine(udp_client); | 83 | UnregisterEngine(udp_client); |
| 77 | UnregisterEngine(tas_input); | 84 | UnregisterEngine(tas_input); |
| 78 | UnregisterEngine(camera); | 85 | UnregisterEngine(camera); |
| @@ -95,8 +102,10 @@ struct InputSubsystem::Impl { | |||
| 95 | devices.insert(devices.end(), keyboard_devices.begin(), keyboard_devices.end()); | 102 | devices.insert(devices.end(), keyboard_devices.begin(), keyboard_devices.end()); |
| 96 | auto mouse_devices = mouse->GetInputDevices(); | 103 | auto mouse_devices = mouse->GetInputDevices(); |
| 97 | devices.insert(devices.end(), mouse_devices.begin(), mouse_devices.end()); | 104 | devices.insert(devices.end(), mouse_devices.begin(), mouse_devices.end()); |
| 105 | #ifdef HAVE_LIBUSB | ||
| 98 | auto gcadapter_devices = gcadapter->GetInputDevices(); | 106 | auto gcadapter_devices = gcadapter->GetInputDevices(); |
| 99 | devices.insert(devices.end(), gcadapter_devices.begin(), gcadapter_devices.end()); | 107 | devices.insert(devices.end(), gcadapter_devices.begin(), gcadapter_devices.end()); |
| 108 | #endif | ||
| 100 | auto udp_devices = udp_client->GetInputDevices(); | 109 | auto udp_devices = udp_client->GetInputDevices(); |
| 101 | devices.insert(devices.end(), udp_devices.begin(), udp_devices.end()); | 110 | devices.insert(devices.end(), udp_devices.begin(), udp_devices.end()); |
| 102 | #ifdef HAVE_SDL2 | 111 | #ifdef HAVE_SDL2 |
| @@ -119,9 +128,11 @@ struct InputSubsystem::Impl { | |||
| 119 | if (engine == mouse->GetEngineName()) { | 128 | if (engine == mouse->GetEngineName()) { |
| 120 | return mouse; | 129 | return mouse; |
| 121 | } | 130 | } |
| 131 | #ifdef HAVE_LIBUSB | ||
| 122 | if (engine == gcadapter->GetEngineName()) { | 132 | if (engine == gcadapter->GetEngineName()) { |
| 123 | return gcadapter; | 133 | return gcadapter; |
| 124 | } | 134 | } |
| 135 | #endif | ||
| 125 | if (engine == udp_client->GetEngineName()) { | 136 | if (engine == udp_client->GetEngineName()) { |
| 126 | return udp_client; | 137 | return udp_client; |
| 127 | } | 138 | } |
| @@ -194,9 +205,11 @@ struct InputSubsystem::Impl { | |||
| 194 | if (engine == mouse->GetEngineName()) { | 205 | if (engine == mouse->GetEngineName()) { |
| 195 | return true; | 206 | return true; |
| 196 | } | 207 | } |
| 208 | #ifdef HAVE_LIBUSB | ||
| 197 | if (engine == gcadapter->GetEngineName()) { | 209 | if (engine == gcadapter->GetEngineName()) { |
| 198 | return true; | 210 | return true; |
| 199 | } | 211 | } |
| 212 | #endif | ||
| 200 | if (engine == udp_client->GetEngineName()) { | 213 | if (engine == udp_client->GetEngineName()) { |
| 201 | return true; | 214 | return true; |
| 202 | } | 215 | } |
| @@ -217,7 +230,9 @@ struct InputSubsystem::Impl { | |||
| 217 | void BeginConfiguration() { | 230 | void BeginConfiguration() { |
| 218 | keyboard->BeginConfiguration(); | 231 | keyboard->BeginConfiguration(); |
| 219 | mouse->BeginConfiguration(); | 232 | mouse->BeginConfiguration(); |
| 233 | #ifdef HAVE_LIBUSB | ||
| 220 | gcadapter->BeginConfiguration(); | 234 | gcadapter->BeginConfiguration(); |
| 235 | #endif | ||
| 221 | udp_client->BeginConfiguration(); | 236 | udp_client->BeginConfiguration(); |
| 222 | #ifdef HAVE_SDL2 | 237 | #ifdef HAVE_SDL2 |
| 223 | sdl->BeginConfiguration(); | 238 | sdl->BeginConfiguration(); |
| @@ -227,7 +242,9 @@ struct InputSubsystem::Impl { | |||
| 227 | void EndConfiguration() { | 242 | void EndConfiguration() { |
| 228 | keyboard->EndConfiguration(); | 243 | keyboard->EndConfiguration(); |
| 229 | mouse->EndConfiguration(); | 244 | mouse->EndConfiguration(); |
| 245 | #ifdef HAVE_LIBUSB | ||
| 230 | gcadapter->EndConfiguration(); | 246 | gcadapter->EndConfiguration(); |
| 247 | #endif | ||
| 231 | udp_client->EndConfiguration(); | 248 | udp_client->EndConfiguration(); |
| 232 | #ifdef HAVE_SDL2 | 249 | #ifdef HAVE_SDL2 |
| 233 | sdl->EndConfiguration(); | 250 | sdl->EndConfiguration(); |
| @@ -248,7 +265,6 @@ struct InputSubsystem::Impl { | |||
| 248 | 265 | ||
| 249 | std::shared_ptr<Keyboard> keyboard; | 266 | std::shared_ptr<Keyboard> keyboard; |
| 250 | std::shared_ptr<Mouse> mouse; | 267 | std::shared_ptr<Mouse> mouse; |
| 251 | std::shared_ptr<GCAdapter> gcadapter; | ||
| 252 | std::shared_ptr<TouchScreen> touch_screen; | 268 | std::shared_ptr<TouchScreen> touch_screen; |
| 253 | std::shared_ptr<TasInput::Tas> tas_input; | 269 | std::shared_ptr<TasInput::Tas> tas_input; |
| 254 | std::shared_ptr<CemuhookUDP::UDPClient> udp_client; | 270 | std::shared_ptr<CemuhookUDP::UDPClient> udp_client; |
| @@ -256,6 +272,10 @@ struct InputSubsystem::Impl { | |||
| 256 | std::shared_ptr<VirtualAmiibo> virtual_amiibo; | 272 | std::shared_ptr<VirtualAmiibo> virtual_amiibo; |
| 257 | std::shared_ptr<VirtualGamepad> virtual_gamepad; | 273 | std::shared_ptr<VirtualGamepad> virtual_gamepad; |
| 258 | 274 | ||
| 275 | #ifdef HAVE_LIBUSB | ||
| 276 | std::shared_ptr<GCAdapter> gcadapter; | ||
| 277 | #endif | ||
| 278 | |||
| 259 | #ifdef HAVE_SDL2 | 279 | #ifdef HAVE_SDL2 |
| 260 | std::shared_ptr<SDLDriver> sdl; | 280 | std::shared_ptr<SDLDriver> sdl; |
| 261 | #endif | 281 | #endif |