Added CMake support for SDL3.
Now supports including SDL2 or SDL3 as a subdirectory within the project. The system will first check for SDL3, then SDL2. If neither is found, it will attempt find_package(SDL3), followed by find_package(SDL2). If all these checks fail, the process will terminate with an error.
This commit is contained in:
Karim Ahmed
2025-07-24 09:48:52 +01:00
parent 9a042bc9ad
commit 32960af1dc
2 changed files with 46 additions and 5 deletions

View File

@ -52,13 +52,27 @@
#ifndef SDL_ENABLE_OLD_NAMES
#define SDL_ENABLE_OLD_NAMES // Just in case we're on SDL3, we need some in-between compatibily
#endif
#include "SDL.h" // SDL base library (window/rendered, input, timing... functionality)
// SDL base library (window/rendered, input, timing... functionality)
#ifdef USING_SDL3_PROJECT
#include "SDL3/SDL.h"
#elif USING_SDL2_PROJECT
#include "SDL2/SDL.h"
#else
#include "SDL.h"
#endif
#if defined(GRAPHICS_API_OPENGL_ES2)
// It seems it does not need to be included to work
//#include "SDL_opengles2.h"
#else
#include "SDL_opengl.h" // SDL OpenGL functionality (if required, instead of internal renderer)
// SDL OpenGL functionality (if required, instead of internal renderer)
#ifdef USING_SDL3_PROJECT
#include "SDL3/SDL_opengl.h"
#elif USING_SDL2_PROJECT
#include "SDL2/SDL_opengl.h"
#else
#include "SDL_opengl.h"
#endif
#endif
//----------------------------------------------------------------------------------