Skip to content

Commit bb0c784

Browse files
authored
[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
1 parent 6cf38b6 commit bb0c784

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

cmake/LibraryConfigurations.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ if(POLICY CMP0072)
77
cmake_policy(SET CMP0072 NEW)
88
endif()
99

10+
set(RAYLIB_DEPENDENCIES "include(CMakeFindDependencyMacro)")
11+
1012
if (${PLATFORM} MATCHES "Desktop")
1113
set(PLATFORM_CPP "PLATFORM_DESKTOP")
1214

@@ -120,15 +122,17 @@ elseif ("${PLATFORM}" MATCHES "SDL")
120122
find_package(SDL3 QUIET)
121123
if(SDL3_FOUND)
122124
message(STATUS "Found SDL3 via find_package()")
125+
set(LIBS_PUBLIC SDL3::SDL3)
126+
set(RAYLIB_DEPENDENCIES "${RAYLIB_DEPENDENCIES}\nfind_dependency(SDL3 REQUIRED)")
123127
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
124-
set(LIBS_PRIVATE SDL3::SDL3)
125128
add_compile_definitions(USING_SDL3_PACKAGE)
126129
else()
127130
# Fallback to SDL2
128131
find_package(SDL2 REQUIRED)
129132
message(STATUS "Found SDL2 via find_package()")
130133
set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL")
131-
set(LIBS_PRIVATE SDL2::SDL2)
134+
set(LIBS_PUBLIC SDL2::SDL2)
135+
set(RAYLIB_DEPENDENCIES "${RAYLIB_DEPENDENCIES}\nfind_dependency(SDL3 REQUIRED)")
132136
add_compile_definitions(USING_SDL2_PACKAGE)
133137
endif()
134138
endif()

cmake/raylib-config.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
@PACKAGE_INIT@
2+
@RAYLIB_DEPENDENCIES@
3+
24
include("${CMAKE_CURRENT_LIST_DIR}/raylib-targets.cmake")

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ if (BUILD_SHARED_LIBS)
9292
endif ()
9393

9494
target_link_libraries(raylib PRIVATE $<BUILD_INTERFACE:${LIBS_PRIVATE}>)
95+
target_link_libraries(raylib PUBLIC ${LIBS_PUBLIC})
9596

9697
# Sets some compile time definitions for the pre-processor
9798
# If CUSTOMIZE_BUILD option is on you will not use config.h by default

0 commit comments

Comments
 (0)