libsdl-org / setup-sdl

GitHub action for providing SDL.
The Unlicense
24 stars 2 forks source link
actions sdl sdl2 sdl3

setup-sdl

This GitHub action downloads, builds and installs SDL and its satellite libraries from source.

By caching the result, subsequent workflow runs will be fast(er).

Usage

name: "sdl"
on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: libsdl-org/setup-sdl@main
        id: sdl
        with:
          install-linux-dependencies: true
          version: 2-latest
          version-sdl-image: 2-latest

      - name: 'Configure and build your project'
        run: |
          cmake -S . -B build
          cmake --build build --verbose

CMake

This action will build SDL using the default c/c++ toolchain, with CMake configuring the build.

An alternative build toolchain can be configured by using a CMake toolchain file.

versions

Using the version option, a SDL release can be used or the latest git tag:

Using the version-sdl-* inputs, it is possible to install the satellite libraries. They accept the same kind of input as version.

Options

See action.yml for an overview of all options, and its defaults.

FAQ

My CMake project does not find SDL

First, make sure you're looking for SDL using find_package:

# SDL2
find_package(SDL2 REQUIRED CONFIG)

# SDL3
find_package(SDL3 REQUIRED CONFIG)

If CMake is still not able to find SDL, the minimum required CMake version of your project is probably less than 3.12. Since this version, CMake will also look for packages using environment variables as hints (see CMP0074).

When bumping the minimum required CMake version is not desirable, here are 2 alternative methods (pick one!):

install-linux-dependencies does things on non-Linux GitHub runners

This input will be renamed to install-dependencies.