Skip to content

Commit 6854e9b

Browse files
RipleyTomMegamouse
authored andcommitted
Fix building with SDL submodule
1 parent 3894c90 commit 6854e9b

File tree

2 files changed

+38
-45
lines changed

2 files changed

+38
-45
lines changed

3rdparty/CMakeLists.txt

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,29 @@ endif()
208208
# AsmJit
209209
add_subdirectory(asmjit EXCLUDE_FROM_ALL)
210210

211+
# SDL3
212+
set(SDL3_TARGET 3rdparty_dummy_lib)
213+
if(USE_SDL)
214+
if(USE_SYSTEM_SDL)
215+
find_package(SDL3)
216+
if(SDL3_FOUND AND SDL3_VERSION VERSION_GREATER_EQUAL 3.2.0)
217+
message(STATUS "Using system SDL3 version '${SDL3_VERSION}'")
218+
add_library(3rdparty_sdl3 INTERFACE)
219+
target_compile_definitions(3rdparty_sdl3 INTERFACE -DHAVE_SDL3=1)
220+
target_link_libraries(3rdparty_sdl3 INTERFACE SDL3::SDL3)
221+
set(SDL3_TARGET 3rdparty_sdl3)
222+
else()
223+
message(FATAL_ERROR "SDL3 is not available on this system")
224+
endif()
225+
else()
226+
message(STATUS "Using static SDL3 from 3rdparty")
227+
add_subdirectory(libsdl-org EXCLUDE_FROM_ALL)
228+
target_compile_definitions(SDL3-static INTERFACE -DHAVE_SDL3=1)
229+
set(SDL3_TARGET SDL3-static)
230+
set(SDL3_DIR "${CMAKE_CURRENT_BINARY_DIR}/libsdl-org/SDL" CACHE STRING "")
231+
endif()
232+
endif()
233+
211234
# OpenAL
212235
if (NOT ANDROID)
213236
add_subdirectory(OpenAL EXCLUDE_FROM_ALL)
@@ -222,31 +245,31 @@ if(USE_FAUDIO)
222245
# FAudio depends on SDL3
223246
find_package(SDL3)
224247
if (USE_SYSTEM_FAUDIO)
225-
if (NOT SDL3_FOUND OR SDL3_VERSION VERSION_LESS 3.2.0)
226-
message(WARNING
227-
"RPCS3: System FAudio requires SDL 3.2.0 or newer. Since a valid SDL3"
228-
">=3.2.0 version cannot be found, building with FAudio will be skipped.")
229-
set(USE_FAUDIO OFF CACHE BOOL "Disabled using system FAudio with SDL < 3.2.0" FORCE)
230-
else()
248+
if (SDL3_FOUND AND SDL3_VERSION VERSION_GREATER_EQUAL 3.2.0)
231249
message(STATUS "RPCS3: Using system FAudio")
232250
find_package(FAudio REQUIRED CONFIGS FAudioConfig.cmake FAudio-config.cmake)
233251
add_library(3rdparty_FAudio INTERFACE)
234252
target_link_libraries(3rdparty_FAudio INTERFACE FAudio)
235253
target_compile_definitions(3rdparty_FAudio INTERFACE -DHAVE_FAUDIO)
236254
set(FAUDIO_TARGET 3rdparty_FAudio)
237-
endif()
238-
else()
239-
if (NOT SDL3_FOUND OR SDL3_VERSION VERSION_LESS 3.2.0)
255+
else()
240256
message(WARNING
241-
"-- RPCS3: 3rdparty FAudio requires SDL 3.2.0 or newer. Since a valid SDL3"
257+
"RPCS3: System FAudio requires SDL 3.2.0 or newer. Since a valid SDL3"
242258
">=3.2.0 version cannot be found, building with FAudio will be skipped.")
243-
set(USE_FAUDIO OFF CACHE BOOL "Disabled FAudio with SDL < 3.2.0" FORCE)
244-
else()
259+
set(USE_FAUDIO OFF CACHE BOOL "Disabled using system FAudio with SDL < 3.2.0" FORCE)
260+
endif()
261+
else()
262+
if (SDL3_FOUND AND SDL3_VERSION VERSION_GREATER_EQUAL 3.2.0)
245263
message(STATUS "RPCS3: Using builtin FAudio")
246264
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared library")
247265
add_subdirectory(FAudio EXCLUDE_FROM_ALL)
248266
target_compile_definitions(FAudio-static INTERFACE -DHAVE_FAUDIO)
249267
set(FAUDIO_TARGET FAudio-static)
268+
else()
269+
message(FATAL_ERROR
270+
"-- RPCS3: 3rdparty FAudio requires SDL 3.2.0 or newer. Since a valid SDL3"
271+
">=3.2.0 version cannot be found, building with FAudio will be skipped.")
272+
set(USE_FAUDIO OFF CACHE BOOL "Disabled FAudio with SDL < 3.2.0" FORCE)
250273
endif()
251274
endif()
252275
endif()
@@ -315,29 +338,6 @@ add_subdirectory(wolfssl EXCLUDE_FROM_ALL)
315338
# CURL
316339
add_subdirectory(curl EXCLUDE_FROM_ALL)
317340

318-
# SDL3
319-
set(SDL3_TARGET 3rdparty_dummy_lib)
320-
if(USE_SDL)
321-
if(USE_SYSTEM_SDL)
322-
find_package(SDL3)
323-
if(SDL3_FOUND AND NOT SDL3_VERSION VERSION_LESS 3.2.0)
324-
message(STATUS "Using system SDL3 version '${SDL3_VERSION}'")
325-
add_library(3rdparty_sdl3 INTERFACE)
326-
target_compile_definitions(3rdparty_sdl3 INTERFACE -DHAVE_SDL3=1)
327-
target_link_libraries(3rdparty_sdl3 INTERFACE SDL3::SDL3)
328-
set(SDL3_TARGET 3rdparty_sdl3)
329-
else()
330-
message(FATAL_ERROR "SDL3 is not available on this system")
331-
endif()
332-
else()
333-
message(STATUS "Using static SDL3 from 3rdparty")
334-
add_library(3rdparty_sdl3 INTERFACE)
335-
target_compile_definitions(3rdparty_sdl3 INTERFACE -DHAVE_SDL3=1)
336-
add_subdirectory(libsdl-org EXCLUDE_FROM_ALL)
337-
set(SDL3_TARGET 3rdparty_sdl3)
338-
endif()
339-
endif()
340-
341341
# MINIUPNP
342342
add_subdirectory(miniupnp EXCLUDE_FROM_ALL)
343343

3rdparty/libsdl-org/CMakeLists.txt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
option(SDL2_DISABLE_SDL2MAIN "" ON)
2-
option(SDL2_DISABLE_INSTALL "" ON)
3-
option(SDL2_DISABLE_UNINSTALL "" ON)
4-
option(SDL_SHARED OFF)
5-
set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
6-
option(SDL_STATIC ON)
7-
set(SDL_STATIC_ENABLED_BY_DEFAULT ON)
8-
option(SDL_TEST OFF)
9-
set(SDL_TEST_ENABLED_BY_DEFAULT OFF)
10-
set(OPT_DEF_LIBC ON)
1+
option(SDL_SHARED "Build a shared version of the library" OFF)
2+
option(SDL_STATIC "Build a static version of the library" ON)
3+
option(SDL_TEST_LIBRARY "Build the SDL3_test library" OFF)
114
add_subdirectory(SDL EXCLUDE_FROM_ALL)

0 commit comments

Comments
 (0)