From fa647cc0b90f74116f5318eba6307466da3964ef Mon Sep 17 00:00:00 2001
From: v1993 <v19930312@gmail.com>
Date: Sun, 9 May 2021 18:58:16 +0300
Subject: [PATCH] Only build SDL2 subsystems that we use

While at it, use better way to enable HIDAPI.
---
 externals/CMakeLists.txt | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt
index 5a54d8de1..fe1c088ca 100644
--- a/externals/CMakeLists.txt
+++ b/externals/CMakeLists.txt
@@ -47,9 +47,20 @@ target_include_directories(unicorn-headers INTERFACE ./unicorn/include)
 
 # SDL2
 if (NOT SDL2_FOUND AND ENABLE_SDL2)
+    # Yuzu itself needs: Events Joystick Haptic Sensor Timers
+    # Yuzu-cmd also needs: Video (depends on Loadso/Dlopen)
+    set(SDL_UNUSED_SUBSYSTEMS
+        Atomic Audio Render Power Threads
+        File CPUinfo Filesystem Locale)
+    foreach(_SUB ${SDL_UNUSED_SUBSYSTEMS})
+      string(TOUPPER ${_SUB} _OPT)
+      option(SDL_${_OPT} "" OFF)
+    endforeach()
+
     set(SDL_STATIC ON)
     set(SDL_SHARED OFF)
-    set(OPT_DEF_HIDAPI ON)
+    option(HIDAPI "" ON)
+
     add_subdirectory(SDL EXCLUDE_FROM_ALL)
     add_library(SDL2 ALIAS SDL2-static)
 endif()