From d7a8d385d84fc8a9d40a78676237a2c416133a88 Mon Sep 17 00:00:00 2001 From: Alex James Date: Sat, 16 Jan 2021 02:15:06 -0600 Subject: [PATCH] CMake: Use find_package to find SDL2 This ensures that the SDL2 uses an absolute library path, which is necessary when SDL2 isn't present in the default link directories (e.g. on macOS). --- 3rdparty/CMakeLists.txt | 2 +- rpcs3/Emu/CMakeLists.txt | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index e22ff16471..0a844c5c8b 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -354,7 +354,7 @@ target_link_libraries(3rdparty_openal INTERFACE ${OPENAL_LIBRARY}) set(FAUDIO_TARGET 3rdparty_dummy_lib) if(USE_FAUDIO) # FAudio depends on SDL2 - pkg_check_modules(SDL2 sdl2) + find_package(SDL2) if (NOT SDL2_FOUND OR SDL2_VERSION VERSION_LESS 2.0.9) message("-- RPCS3: FAudio requires SDL 2.0.9 or newer.") else() diff --git a/rpcs3/Emu/CMakeLists.txt b/rpcs3/Emu/CMakeLists.txt index d72efb1e84..1b9c412733 100644 --- a/rpcs3/Emu/CMakeLists.txt +++ b/rpcs3/Emu/CMakeLists.txt @@ -122,9 +122,12 @@ if(USE_PULSE AND PULSE_FOUND) target_link_libraries(rpcs3_emu PUBLIC 3rdparty::pulse) endif() -if(USE_FAUDIO AND SDL2_FOUND AND NOT SDL2_VERSION VERSION_LESS 2.0.9) - target_sources(rpcs3_emu PRIVATE Audio/FAudio/FAudioBackend.cpp) - target_link_libraries(rpcs3_emu PUBLIC 3rdparty::faudio) +if(USE_FAUDIO) + find_package(SDL2) + if(SDL2_FOUND AND NOT SDL2_VERSION VERSION_LESS 2.0.9) + target_sources(rpcs3_emu PRIVATE Audio/FAudio/FAudioBackend.cpp) + target_link_libraries(rpcs3_emu PUBLIC 3rdparty::faudio) + endif() endif() if(WIN32)