[build][cmake] Fix definition to use SDL3 (#5175)

* fix definition to use SDL3

* [cmake] fix definition to use SDL3

* [build][cmake] prefer USING_VERSION_SDL3 over PLATFORM_DESKTOP_SDL3

* [build][cmake] when libs are added externally, consumer needs to import them too
This commit is contained in:
Bruno Cabral
2025-09-13 01:19:44 -07:00
committed by GitHub
parent 6cf38b6292
commit bb0c78476c
3 changed files with 9 additions and 2 deletions

View File

@@ -7,6 +7,8 @@ if(POLICY CMP0072)
cmake_policy(SET CMP0072 NEW) cmake_policy(SET CMP0072 NEW)
endif() endif()
set(RAYLIB_DEPENDENCIES "include(CMakeFindDependencyMacro)")
if (${PLATFORM} MATCHES "Desktop") if (${PLATFORM} MATCHES "Desktop")
set(PLATFORM_CPP "PLATFORM_DESKTOP") set(PLATFORM_CPP "PLATFORM_DESKTOP")
@@ -120,15 +122,17 @@ elseif ("${PLATFORM}" MATCHES "SDL")
find_package(SDL3 QUIET) find_package(SDL3 QUIET)
if(SDL3_FOUND) if(SDL3_FOUND)
message(STATUS "Found SDL3 via find_package()") message(STATUS "Found SDL3 via find_package()")
set(LIBS_PUBLIC SDL3::SDL3)
set(RAYLIB_DEPENDENCIES "${RAYLIB_DEPENDENCIES}\nfind_dependency(SDL3 REQUIRED)")
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL") set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
set(LIBS_PRIVATE SDL3::SDL3)
add_compile_definitions(USING_SDL3_PACKAGE) add_compile_definitions(USING_SDL3_PACKAGE)
else() else()
# Fallback to SDL2 # Fallback to SDL2
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
message(STATUS "Found SDL2 via find_package()") message(STATUS "Found SDL2 via find_package()")
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL") set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
set(LIBS_PRIVATE SDL2::SDL2) set(LIBS_PUBLIC SDL2::SDL2)
set(RAYLIB_DEPENDENCIES "${RAYLIB_DEPENDENCIES}\nfind_dependency(SDL3 REQUIRED)")
add_compile_definitions(USING_SDL2_PACKAGE) add_compile_definitions(USING_SDL2_PACKAGE)
endif() endif()
endif() endif()

View File

@@ -1,2 +1,4 @@
@PACKAGE_INIT@ @PACKAGE_INIT@
@RAYLIB_DEPENDENCIES@
include("${CMAKE_CURRENT_LIST_DIR}/raylib-targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/raylib-targets.cmake")

View File

@@ -92,6 +92,7 @@ if (BUILD_SHARED_LIBS)
endif () endif ()
target_link_libraries(raylib PRIVATE $<BUILD_INTERFACE:${LIBS_PRIVATE}>) target_link_libraries(raylib PRIVATE $<BUILD_INTERFACE:${LIBS_PRIVATE}>)
target_link_libraries(raylib PUBLIC ${LIBS_PUBLIC})
# Sets some compile time definitions for the pre-processor # Sets some compile time definitions for the pre-processor
# If CUSTOMIZE_BUILD option is on you will not use config.h by default # If CUSTOMIZE_BUILD option is on you will not use config.h by default