mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Fixed:
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:
@ -101,10 +101,37 @@ elseif ("${PLATFORM}" MATCHES "DRM")
|
||||
set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} atomic pthread m dl)
|
||||
|
||||
elseif ("${PLATFORM}" MATCHES "SDL")
|
||||
find_package(SDL2 REQUIRED)
|
||||
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
|
||||
set(LIBS_PRIVATE SDL2::SDL2)
|
||||
# First, check if SDL is included as a subdirectory
|
||||
if(TARGET SDL3::SDL3)
|
||||
message(STATUS "Using SDL3 from subdirectory")
|
||||
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
|
||||
set(LIBS_PRIVATE SDL3::SDL3)
|
||||
add_compile_definitions(USING_SDL3_PROJECT)
|
||||
elseif(TARGET SDL2::SDL2)
|
||||
message(STATUS "Using SDL2 from subdirectory")
|
||||
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
|
||||
set(LIBS_PRIVATE SDL2::SDL2)
|
||||
add_compile_definitions(USING_SDL2_PROJECT)
|
||||
else()
|
||||
# No SDL added via add_subdirectory(), try find_package()
|
||||
message(STATUS "No SDL target from subdirectory, searching via find_package()...")
|
||||
|
||||
# First try SDL3
|
||||
find_package(SDL3 QUIET)
|
||||
if(SDL3_FOUND)
|
||||
message(STATUS "Found SDL3 via find_package()")
|
||||
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
|
||||
set(LIBS_PRIVATE SDL3::SDL3)
|
||||
add_compile_definitions(USING_SDL3_PACKAGE)
|
||||
else()
|
||||
# Fallback to SDL2
|
||||
find_package(SDL2 REQUIRED)
|
||||
message(STATUS "Found SDL2 via find_package()")
|
||||
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
|
||||
set(LIBS_PRIVATE SDL2::SDL2)
|
||||
add_compile_definitions(USING_SDL2_PACKAGE)
|
||||
endif()
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (NOT ${OPENGL_VERSION} MATCHES "OFF")
|
||||
|
||||
Reference in New Issue
Block a user