option(SDL2_DISABLE_SDL2MAIN "" ON)
option(SDL2_DISABLE_INSTALL "" ON)
option(SDL2_DISABLE_UNINSTALL "" ON)
option(SDL_SHARED "Build a shared version of the library" OFF)
option(SDL_SHARED_ENABLED_BY_DEFAULT "" OFF)
option(SDL_STATIC "Build a static version of the library" ON)
option(SDL_STATIC_ENABLED_BY_DEFAULT "" ON)
option(SDL_TEST "Build the SDL2_test library" OFF)
option(SDL_TEST_ENABLED_BY_DEFAULT "" OFF)

# SDL fails to clean up old headers after version upgrades, so do that manually
set(EXPECTED_SDL_REVISION "SDL-release-2.30.9-0")
if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/SDL/include/SDL2/SDL_revision.h")
  file(READ "${CMAKE_CURRENT_BINARY_DIR}/SDL/include/SDL2/SDL_revision.h" ACTUAL_SDL_REVISION)
  if (NOT "${ACTUAL_SDL_REVISION}" MATCHES "${EXPECTED_SDL_REVISION}")
    message(STATUS "Found unexpected SDL2/SDL_revision.h, removing generated includes.")
    file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/SDL/include/")
  endif()
endif()
if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/SDL/include/SDL_revision.h")
  file(READ "${CMAKE_CURRENT_BINARY_DIR}/SDL/include/SDL_revision.h" ACTUAL_SDL_REVISION)
  if (NOT "${ACTUAL_SDL_REVISION}" MATCHES "${EXPECTED_SDL_REVISION}")
    message(STATUS "Found unexpected SDL_revision.h, removing generated includes.")
    file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/SDL/include/")
  endif()
endif()

add_subdirectory(SDL)
if (TARGET SDL2)
  dolphin_disable_warnings(SDL2)
endif()
if (TARGET SDL2-static)
  dolphin_disable_warnings(SDL2-static)
endif()
