set(SDL_ATOMIC                  ON  CACHE INTERNAL "")
set(SDL_AUDIO                   OFF CACHE INTERNAL "")
set(SDL_CPUINFO                 ON  CACHE INTERNAL "")
set(SDL_DLOPEN                  ON  CACHE INTERNAL "")
set(SDL_EVENTS                  ON  CACHE INTERNAL "")
set(SDL_FILE                    ON  CACHE INTERNAL "")
set(SDL_FILESYSTEM              OFF CACHE INTERNAL "")
set(SDL_HAPTIC                  ON  CACHE INTERNAL "")
set(SDL_JOYSTICK                ON  CACHE INTERNAL "")
set(SDL_LOADSO                  ON  CACHE INTERNAL "")
set(SDL_LOCALE                  ON  CACHE INTERNAL "")
set(SDL_POWER                   ON  CACHE INTERNAL "")
set(SDL_RENDER                  OFF CACHE INTERNAL "")
set(SDL_SENSOR                  ON  CACHE INTERNAL "")
set(SDL_SHARED                  OFF CACHE INTERNAL "")
set(SDL_STATIC                  ON  CACHE INTERNAL "")
set(SDL_STATIC_PIC              OFF CACHE INTERNAL "")
set(SDL_TEST                    OFF CACHE INTERNAL "")
set(SDL_THREADS                 ON  CACHE INTERNAL "")
set(SDL_TIMERS                  ON  CACHE INTERNAL "")
set(SDL_VIDEO                   ON  CACHE INTERNAL "")
set(SDL_LIBC                    ON  CACHE INTERNAL "Use the system C library")
set(SDL_GCC_ATOMICS             ON  CACHE INTERNAL "Use gcc builtin atomics")
set(SDL_ASSEMBLY                ON  CACHE INTERNAL "Enable assembly routines")
set(SDL_SSEMATH                 OFF CACHE INTERNAL "Allow GCC to use SSE floating point math")
set(SDL_MMX                     OFF CACHE INTERNAL "Use MMX assembly routines")
set(SDL_3DNOW                   OFF CACHE INTERNAL "Use 3Dnow! MMX assembly routines")
set(SDL_SSE                     ON  CACHE INTERNAL "Use SSE assembly routines")
set(SDL_SSE2                    ON  CACHE INTERNAL "Use SSE2 assembly routines")
set(SDL_SSE3                    ON  CACHE INTERNAL "Use SSE3 assembly routines")
set(SDL_ALTIVEC                 OFF CACHE INTERNAL "Use Altivec assembly routines")
set(SDL_ARMSIMD                 OFF CACHE INTERNAL "use SIMD assembly blitters on ARM")
set(SDL_ARMNEON                 OFF CACHE INTERNAL "use NEON assembly blitters on ARM")
set(SDL_DISKAUDIO               OFF CACHE INTERNAL "Support the disk writer audio driver")
set(SDL_DUMMYAUDIO              OFF CACHE INTERNAL "Support the dummy audio driver")
set(SDL_DIRECTFB                OFF CACHE INTERNAL "Use DirectFB video driver")
set(SDL_DIRECTFB_SHARED         OFF CACHE INTERNAL "Dynamically load directfb support")
set(SDL_DUMMYVIDEO              OFF CACHE INTERNAL "Use dummy video driver")
set(SDL_OPENGL                  OFF CACHE INTERNAL "Include OpenGL support")
set(SDL_OPENGLES                OFF CACHE INTERNAL "Include OpenGL ES support")
set(SDL_PTHREADS                OFF CACHE INTERNAL "Use POSIX threads for multi-threading")
set(SDL_PTHREADS_SEM            OFF CACHE INTERNAL "Use pthread semaphores")
set(SDL_OSS                     OFF CACHE INTERNAL "Support the OSS audio API")
set(SDL_ALSA                    OFF CACHE INTERNAL "Support the ALSA audio API")
set(SDL_ALSA_SHARED             OFF CACHE INTERNAL "Dynamically load ALSA audio support")
set(SDL_JACK                    OFF CACHE INTERNAL "Support the JACK audio API")
set(SDL_JACK_SHARED             OFF CACHE INTERNAL "Dynamically load JACK audio support")
set(SDL_ESD                     OFF CACHE INTERNAL "Support the Enlightened Sound Daemon")
set(SDL_ESD_SHARED              OFF CACHE INTERNAL "Dynamically load ESD audio support")
set(SDL_PIPEWIRE                OFF CACHE INTERNAL "Use Pipewire audio")
set(SDL_PIPEWIRE_SHARED         OFF CACHE INTERNAL "Dynamically load Pipewire support")
set(SDL_PULSEAUDIO              OFF CACHE INTERNAL "Use PulseAudio")
set(SDL_PULSEAUDIO_SHARED       OFF CACHE INTERNAL "Dynamically load PulseAudio support")
set(SDL_ARTS                    OFF CACHE INTERNAL "Support the Analog Real Time Synthesizer")
set(SDL_ARTS_SHARED             OFF CACHE INTERNAL "Dynamically load aRts audio support")
set(SDL_NAS                     OFF CACHE INTERNAL "Support the NAS audio API")
set(SDL_NAS_SHARED              OFF CACHE INTERNAL "Dynamically load NAS audio support")
set(SDL_SNDIO                   OFF CACHE INTERNAL "Support the sndio audio API")
set(SDL_SNDIO_SHARED            OFF CACHE INTERNAL "Dynamically load the sndio audio API")
set(SDL_FUSIONSOUND             OFF CACHE INTERNAL "Use FusionSound audio driver")
set(SDL_FUSIONSOUND_SHARED      OFF CACHE INTERNAL "Dynamically load fusionsound audio support")
set(SDL_LIBSAMPLERATE           OFF CACHE INTERNAL "Use libsamplerate for audio rate conversion")
set(SDL_LIBSAMPLERATE_SHARED    OFF CACHE INTERNAL  "Dynamically load libsamplerate" ON "SDL_LIBSAMPLERATE")
set(SDL_RPATH                   OFF CACHE INTERNAL "Use an rpath when linking SDL")
set(SDL_CLOCK_GETTIME           OFF CACHE INTERNAL "Use clock_gettime() instead of gettimeofday()")
set(SDL_X11                     OFF CACHE INTERNAL "Use X11 video driver")
set(SDL_X11_SHARED              OFF CACHE INTERNAL "Dynamically load X11 support")
set(SDL_WAYLAND                 OFF CACHE INTERNAL "Use Wayland video driver")
set(SDL_WAYLAND_SHARED          OFF CACHE INTERNAL "Dynamically load Wayland support")
set(SDL_WAYLAND_LIBDECOR        OFF CACHE INTERNAL "Use client-side window decorations on Wayland")
set(SDL_WAYLAND_LIBDECOR_SHARED OFF CACHE INTERNAL "Dynamically load libdecor support")
set(SDL_WAYLAND_QT_TOUCH        OFF CACHE INTERNAL "QtWayland server support for Wayland video driver")
set(SDL_RPI                     OFF CACHE INTERNAL "Use Raspberry Pi video driver")
set(SDL_COCOA                   OFF CACHE INTERNAL "Use Cocoa video driver")
set(SDL_DIRECTX                 OFF CACHE INTERNAL "Use DirectX for Windows audio/video")
set(SDL_XINPUT                  ON  CACHE INTERNAL "Use Xinput for Windows")
set(SDL_WASAPI                  OFF CACHE INTERNAL "Use the Windows WASAPI audio driver")
set(SDL_RENDER_D3D              OFF CACHE INTERNAL "Enable the Direct3D render driver")
set(SDL_RENDER_METAL            OFF CACHE INTERNAL "Enable the Metal render driver")
set(SDL_VIVANTE                 OFF CACHE INTERNAL "Use Vivante EGL video driver")
set(SDL_VULKAN                  ON  CACHE INTERNAL "Enable Vulkan support")
set(SDL_METAL                   OFF CACHE INTERNAL "Enable Metal support")
set(SDL_KMSDRM                  OFF CACHE INTERNAL "Use KMS DRM video driver")
set(SDL_KMSDRM_SHARED           OFF CACHE INTERNAL "Dynamically load KMS DRM support" ON "SDL_KMSDRM")
set(SDL_OFFSCREEN               OFF CACHE INTERNAL "Use offscreen video driver")
set(SDL_HIDAPI                  OFF CACHE INTERNAL "Use HIDAPI for low level joystick drivers")
set(SDL_VIRTUAL_JOYSTICK        OFF CACHE INTERNAL "Enable the virtual-joystick driver")
set(SDL_ASAN                    OFF CACHE INTERNAL "Use AddressSanitizer to detect memory errors")

captal_download_submodule(apyre/external/sdl TRUE)
add_subdirectory(external/sdl EXCLUDE_FROM_ALL)

unset(SDL_ATOMIC                  CACHE)
unset(SDL_AUDIO                   CACHE)
unset(SDL_CMAKE_DEBUG_POSTFIX     CACHE)
unset(SDL_CPUINFO                 CACHE)
unset(SDL_DLOPEN                  CACHE)
unset(SDL_EVENTS                  CACHE)
unset(SDL_FILE                    CACHE)
unset(SDL_FILESYSTEM              CACHE)
unset(SDL_HAPTIC                  CACHE)
unset(SDL_JOYSTICK                CACHE)
unset(SDL_LOADSO                  CACHE)
unset(SDL_LOCALE                  CACHE)
unset(SDL_POWER                   CACHE)
unset(SDL_RENDER                  CACHE)
unset(SDL_SENSOR                  CACHE)
unset(SDL_SHARED                  CACHE)
unset(SDL_STATIC                  CACHE)
unset(SDL_STATIC_PIC              CACHE)
unset(SDL_TEST                    CACHE)
unset(SDL_THREADS                 CACHE)
unset(SDL_TIMERS                  CACHE)
unset(SDL_VIDEO                   CACHE)
unset(SDL_LIBC                    CACHE)
unset(SDL_GCC_ATOMICS             CACHE)
unset(SDL_ASSEMBLY                CACHE)
unset(SDL_SSEMATH                 CACHE)
unset(SDL_MMX                     CACHE)
unset(SDL_3DNOW                   CACHE)
unset(SDL_SSE                     CACHE)
unset(SDL_SSE2                    CACHE)
unset(SDL_SSE3                    CACHE)
unset(SDL_ALTIVEC                 CACHE)
unset(SDL_ARMSIMD                 CACHE)
unset(SDL_ARMNEON                 CACHE)
unset(SDL_DISKAUDIO               CACHE)
unset(SDL_DUMMYAUDIO              CACHE)
unset(SDL_DIRECTFB                CACHE)
unset(SDL_DIRECTFB_SHARED         CACHE)
unset(SDL_DUMMYVIDEO              CACHE)
unset(SDL_OPENGL                  CACHE)
unset(SDL_OPENGLES                CACHE)
unset(SDL_PTHREADS                CACHE)
unset(SDL_PTHREADS_SEM            CACHE)
unset(SDL_OSS                     CACHE)
unset(SDL_ALSA                    CACHE)
unset(SDL_ALSA_SHARED             CACHE)
unset(SDL_JACK                    CACHE)
unset(SDL_JACK_SHARED             CACHE)
unset(SDL_ESD                     CACHE)
unset(SDL_ESD_SHARED              CACHE)
unset(SDL_PIPEWIRE                CACHE)
unset(SDL_PIPEWIRE_SHARED         CACHE)
unset(SDL_PULSEAUDIO              CACHE)
unset(SDL_PULSEAUDIO_SHARED       CACHE)
unset(SDL_ARTS                    CACHE)
unset(SDL_ARTS_SHARED             CACHE)
unset(SDL_NAS                     CACHE)
unset(SDL_NAS_SHARED              CACHE)
unset(SDL_SNDIO                   CACHE)
unset(SDL_SNDIO_SHARED            CACHE)
unset(SDL_FUSIONSOUND             CACHE)
unset(SDL_FUSIONSOUND_SHARED      CACHE)
unset(SDL_LIBSAMPLERATE           CACHE)
unset(SDL_LIBSAMPLERATE_SHARED    CACHE)
unset(SDL_RPATH                   CACHE)
unset(SDL_CLOCK_GETTIME           CACHE)
unset(SDL_X11                     CACHE)
unset(SDL_X11_SHARED              CACHE)
unset(SDL_WAYLAND                 CACHE)
unset(SDL_WAYLAND_SHARED          CACHE)
unset(SDL_WAYLAND_LIBDECOR        CACHE)
unset(SDL_WAYLAND_LIBDECOR_SHARED CACHE)
unset(SDL_WAYLAND_QT_TOUCH        CACHE)
unset(SDL_RPI                     CACHE)
unset(SDL_COCOA                   CACHE)
unset(SDL_DIRECTX                 CACHE)
unset(SDL_XINPUT                  CACHE)
unset(SDL_WASAPI                  CACHE)
unset(SDL_RENDER_D3D              CACHE)
unset(SDL_RENDER_METAL            CACHE)
unset(SDL_VIVANTE                 CACHE)
unset(SDL_VULKAN                  CACHE)
unset(SDL_METAL                   CACHE)
unset(SDL_KMSDRM                  CACHE)
unset(SDL_KMSDRM_SHARED           CACHE)
unset(SDL_OFFSCREEN               CACHE)
unset(SDL_HIDAPI                  CACHE)
unset(SDL_VIRTUAL_JOYSTICK        CACHE)
unset(SDL_ASAN                    CACHE)