Skip to content

Add FindSDL for use with CMake #24300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions cmake/Modules/FindSDL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Locate SDL
# This module defines:
# SDL_FOUND - system has SDL
# SDL_INCLUDE_DIR - the SDL include directory
# SDL_LIBRARIES - Link these to use SDL

# The implementation is based on the standard FindSDL.cmake provided with CMake,
# but customized for targeting Emscripten only.

# These libraries are provided with Emscripten
SET(SDL_FOUND TRUE)

# This is the path where <SDL.h> is found
SET(SDL_INCLUDE_DIR "${EMSCRIPTEN_SYSROOT}/include/SDL")
SET(SDL_INCLUDE_DIRS ${SDL_INCLUDE_DIR})

SET(SDL_LIBRARY SDL)
SET(SDL_LIBRARIES ${SDL_LIBRARY})

set(SDL_VERSION_MAJOR 1)
set(SDL_VERSION_MINOR 3)
set(SDL_VERSION_PATCH 0)
set(SDL_VERSION ${SDL_VERSION_MAJOR}.${SDL_VERSION_MINOR}.${SDL_VERSION_PATCH})

mark_as_advanced(
SDL_INCLUDE_DIR
SDL_LIBRARY
)

if (NOT TARGET SDL::SDL)
add_library(SDL::SDL INTERFACE IMPORTED)
set_target_properties(SDL::SDL PROPERTIES
IMPORTED_LIBNAME "${SDL_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL_INCLUDE_DIR}"
)
endif()