--- CMakeLists.txt.orig	2024-04-13 12:55:23 UTC
+++ CMakeLists.txt
@@ -143,11 +143,14 @@ if(NOT OPTION_DEDICATED)
         find_package(Allegro)
         if(NOT APPLE)
             find_package(Freetype)
+if(WITH_SDL2)
             find_package(SDL2)
-            if(NOT SDL2_FOUND)
+else()
                 find_package(SDL)
             endif()
+if(WITH_FLUIDSYNTH)
             find_package(Fluidsynth)
+endif()
             if(Freetype_FOUND)
                 find_package(Fontconfig)
             endif()
@@ -323,9 +326,14 @@ if(NOT EMSCRIPTEN)
 endif()
 
 if(NOT OPTION_DEDICATED)
+  if(WITH_FLUIDSYNTH)
     link_package(Fluidsynth)
+  endif()
+  if(NOT WITH_SDL2)
     link_package(SDL)
+  else()
     link_package(SDL2 TARGET SDL2::SDL2)
+  endif()
     link_package(Allegro)
     link_package(FREETYPE TARGET Freetype::Freetype)
     link_package(Fontconfig TARGET Fontconfig::Fontconfig)
