Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Restore buildability with SDL 2.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Mar 21, 2024
1 parent bcb952c commit 1247087
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/build.yml
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -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
Expand Down

0 comments on commit 1247087

Please sign in to comment.