Restore buildability with SDL 2.0.10

This commit is contained in:
sfan5 2024-03-21 22:42:35 +01:00
parent bcb952c3ca
commit 124708784f
2 changed files with 22 additions and 5 deletions

@ -61,8 +61,7 @@ jobs:
LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest ogles2
linux-sdl:
# something is wrong with the SDL cmake files on 20.04
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install deps
@ -106,8 +105,7 @@ jobs:
LIBGL_ALWAYS_SOFTWARE=true xvfb-run ./AutomatedTest opengl3
linux-sdl-gles2:
# something is wrong with the SDL cmake files on 20.04
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install deps

@ -265,8 +265,27 @@ if(ENABLE_OPENGL OR ENABLE_OPENGL3)
find_package(OpenGL REQUIRED)
endif()
if(USE_SDL2)
find_package(SDL2 2.0.10 CONFIG REQUIRED)
find_package(SDL2 REQUIRED)
message(STATUS "Found SDL2: ${SDL2_LIBRARIES}")
# unfortunately older SDL does not provide its version to cmake, so check header.
set(CMAKE_REQUIRED_INCLUDES ${SDL2_INCLUDE_DIRS})
unset(CHECK_SDL_VERSION CACHE)
check_cxx_source_compiles("#include <SDL_version.h>\n\
#if !SDL_VERSION_ATLEAST(2, 0, 10)\n\
#error\n\
#endif\n\
int main() {}" CHECK_SDL_VERSION)
if(NOT CHECK_SDL_VERSION)
message(FATAL_ERROR "SDL2 is too old, required is at least 2.0.10!")
endif()
# ...no target either.
if(NOT TARGET SDL2::SDL2)
add_library(SDL2::SDL2 SHARED IMPORTED)
set_target_properties(SDL2::SDL2 PROPERTIES
IMPORTED_LOCATION "${SDL2_LIBRARIES}")
endif()
endif()
# More special config