CMake: Use dynamic SDL2 on all platforms

This commit is contained in:
Stenzek 2023-07-19 23:09:04 +10:00 committed by Connor McLaughlin
parent 8276054671
commit 3567d8913f
7 changed files with 37 additions and 22 deletions

View File

@ -4,7 +4,7 @@ set -e
INSTALLDIR="$HOME/deps" INSTALLDIR="$HOME/deps"
NPROCS="$(getconf _NPROCESSORS_ONLN)" NPROCS="$(getconf _NPROCESSORS_ONLN)"
SDL=SDL2-2.28.1 SDL=SDL2-2.28.2
QT=6.5.2 QT=6.5.2
LIBBACKTRACE=ad106d5fdd5d960bd33fae1c48a351af567fd075 LIBBACKTRACE=ad106d5fdd5d960bd33fae1c48a351af567fd075
@ -12,7 +12,7 @@ mkdir -p deps-build
cd deps-build cd deps-build
cat > SHASUMS <<EOF cat > SHASUMS <<EOF
4977ceba5c0054dbe6c2f114641aced43ce3bf2b41ea64b6a372d6ba129cb15d $SDL.tar.gz 64b1102fa22093515b02ef33dd8739dee1ba57e9dbba6a092942b8bbed1a1c5e $SDL.tar.gz
fd6f417fe9e3a071cf1424a5152d926a34c4a3c5070745470be6cf12a404ed79 $LIBBACKTRACE.zip fd6f417fe9e3a071cf1424a5152d926a34c4a3c5070745470be6cf12a404ed79 $LIBBACKTRACE.zip
3db4c729b4d80a9d8fda8dd77128406353baff4755ca619177eda4cddae71269 qtbase-everywhere-src-$QT.tar.xz 3db4c729b4d80a9d8fda8dd77128406353baff4755ca619177eda4cddae71269 qtbase-everywhere-src-$QT.tar.xz
aae0c08924c6a5e47f9d57e031673d611ffff7aab2bee2e1cc460471ecac6743 qtimageformats-everywhere-src-$QT.tar.xz aae0c08924c6a5e47f9d57e031673d611ffff7aab2bee2e1cc460471ecac6743 qtimageformats-everywhere-src-$QT.tar.xz

View File

@ -28,8 +28,8 @@
"sources": [ "sources": [
{ {
"type": "archive", "type": "archive",
"url": "https://libsdl.org/release/SDL2-2.28.1.tar.gz", "url": "https://libsdl.org/release/SDL2-2.28.2.tar.gz",
"sha256": "4977ceba5c0054dbe6c2f114641aced43ce3bf2b41ea64b6a372d6ba129cb15d" "sha256": "64b1102fa22093515b02ef33dd8739dee1ba57e9dbba6a092942b8bbed1a1c5e"
} }
], ],
"cleanup": [ "cleanup": [

View File

@ -6,7 +6,7 @@ export MACOSX_DEPLOYMENT_TARGET=10.14
INSTALLDIR="$HOME/deps" INSTALLDIR="$HOME/deps"
NPROCS="$(getconf _NPROCESSORS_ONLN)" NPROCS="$(getconf _NPROCESSORS_ONLN)"
SDL=SDL2-2.28.1 SDL=SDL2-2.28.2
PNG=1.6.37 PNG=1.6.37
JPG=9e JPG=9e
SOUNDTOUCH=soundtouch-2.3.1 SOUNDTOUCH=soundtouch-2.3.1
@ -22,7 +22,7 @@ export CFLAGS="-I$INSTALLDIR/include -Os $CFLAGS"
export CXXFLAGS="-I$INSTALLDIR/include -Os $CXXFLAGS" export CXXFLAGS="-I$INSTALLDIR/include -Os $CXXFLAGS"
cat > SHASUMS <<EOF cat > SHASUMS <<EOF
4977ceba5c0054dbe6c2f114641aced43ce3bf2b41ea64b6a372d6ba129cb15d $SDL.tar.gz 64b1102fa22093515b02ef33dd8739dee1ba57e9dbba6a092942b8bbed1a1c5e $SDL.tar.gz
505e70834d35383537b6491e7ae8641f1a4bed1876dbfe361201fc80868d88ca libpng-$PNG.tar.xz 505e70834d35383537b6491e7ae8641f1a4bed1876dbfe361201fc80868d88ca libpng-$PNG.tar.xz
4077d6a6a75aeb01884f708919d25934c93305e49f7e3f36db9129320e6f4f3d jpegsrc.v$JPG.tar.gz 4077d6a6a75aeb01884f708919d25934c93305e49f7e3f36db9129320e6f4f3d jpegsrc.v$JPG.tar.gz
6900996607258496ce126924a19fe9d598af9d892cf3f33d1e4daaa9b42ae0b1 $SOUNDTOUCH.tar.gz 6900996607258496ce126924a19fe9d598af9d892cf3f33d1e4daaa9b42ae0b1 $SOUNDTOUCH.tar.gz

View File

@ -10,7 +10,6 @@ set(USE_SYSTEM_LIBS "AUTO" CACHE STRING "Use system libraries instead of bundled
set(DEFAULT_USE_SYSTEM_RYML OFF) # System rapidyaml causes a lot of problems set(DEFAULT_USE_SYSTEM_RYML OFF) # System rapidyaml causes a lot of problems
optional_system_library(fmt) optional_system_library(fmt)
optional_system_library(ryml) optional_system_library(ryml)
optional_system_library(SDL2)
option(LTO_PCSX2_CORE "Enable LTO/IPO/LTCG on the subset of pcsx2 that benefits most from it but not anything else") option(LTO_PCSX2_CORE "Enable LTO/IPO/LTCG on the subset of pcsx2 that benefits most from it but not anything else")
option(USE_VTUNE "Plug VTUNE to profile GS JIT.") option(USE_VTUNE "Plug VTUNE to profile GS JIT.")
option(USE_ACHIEVEMENTS "Build with RetroAchievements support" ON) option(USE_ACHIEVEMENTS "Build with RetroAchievements support" ON)

View File

@ -78,10 +78,6 @@ else()
endif() endif()
endif() endif()
if(NOT QT_BUILD)
find_optional_system_library(SDL2 3rdparty/sdl2 2.0.12)
endif()
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
find_package(X11 REQUIRED) find_package(X11 REQUIRED)
make_imported_target_if_missing(X11::X11 X11) make_imported_target_if_missing(X11::X11 X11)
@ -99,6 +95,9 @@ endif(WIN32)
# Require threads on all OSes. # Require threads on all OSes.
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
# Also need SDL2.
find_package(SDL2 2.28.2 REQUIRED)
set(ACTUALLY_ENABLE_TESTS ${ENABLE_TESTS}) set(ACTUALLY_ENABLE_TESTS ${ENABLE_TESTS})
if(ENABLE_TESTS) if(ENABLE_TESTS)
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/3rdparty/gtest/CMakeLists.txt") if(NOT EXISTS "${CMAKE_SOURCE_DIR}/3rdparty/gtest/CMakeLists.txt")
@ -136,9 +135,6 @@ if(QT_BUILD)
endif() endif()
endif() endif()
# We use the bundled (latest) SDL version for Qt.
find_optional_system_library(SDL2 3rdparty/sdl2 2.0.22)
# rcheevos backend for RetroAchievements. # rcheevos backend for RetroAchievements.
if(USE_ACHIEVEMENTS) if(USE_ACHIEVEMENTS)
add_subdirectory(3rdparty/rcheevos EXCLUDE_FROM_ALL) add_subdirectory(3rdparty/rcheevos EXCLUDE_FROM_ALL)

View File

@ -56,14 +56,9 @@ if(USE_LINKED_FFMPEG)
target_link_libraries(PCSX2_FLAGS INTERFACE FFMPEG::avcodec FFMPEG::avformat FFMPEG::avutil FFMPEG::swscale FFMPEG::swresample) target_link_libraries(PCSX2_FLAGS INTERFACE FFMPEG::avcodec FFMPEG::avformat FFMPEG::avutil FFMPEG::swscale FFMPEG::swresample)
endif() endif()
if(TARGET SDL2::SDL2 OR TARGET SDL2::SDL2-static) if(TARGET SDL2::SDL2)
target_compile_definitions(PCSX2_FLAGS INTERFACE SDL_BUILD) target_compile_definitions(PCSX2_FLAGS INTERFACE SDL_BUILD)
if ("${SDL2_TYPE}" STREQUAL Bundled) target_link_libraries(PCSX2_FLAGS INTERFACE SDL2::SDL2)
# Use our in-tree SDL build.
target_link_libraries(PCSX2_FLAGS INTERFACE SDL2::SDL2-static)
else()
target_link_libraries(PCSX2_FLAGS INTERFACE SDL2::SDL2)
endif()
target_sources(PCSX2 PRIVATE target_sources(PCSX2 PRIVATE
Input/SDLInputSource.cpp Input/SDLInputSource.cpp
Input/SDLInputSource.h Input/SDLInputSource.h
@ -474,7 +469,7 @@ if(CUBEB_API)
list(APPEND pcsx2USBHeaders USB/usb-mic/audiodev-cubeb.h) list(APPEND pcsx2USBHeaders USB/usb-mic/audiodev-cubeb.h)
endif() endif()
if(TARGET SDL2::SDL2 OR TARGET SDL2::SDL2-static) if(TARGET SDL2::SDL2)
list(APPEND pcsx2USBSources USB/usb-pad/usb-pad-sdl-ff.cpp) list(APPEND pcsx2USBSources USB/usb-pad/usb-pad-sdl-ff.cpp)
list(APPEND pcsx2USBHeaders USB/usb-pad/usb-pad-sdl-ff.h) list(APPEND pcsx2USBHeaders USB/usb-pad/usb-pad-sdl-ff.h)
endif() endif()
@ -1306,6 +1301,17 @@ function(setup_main_executable target)
if(MSVC) if(MSVC)
install(FILES $<TARGET_PDB_FILE:${target}> DESTINATION ${CMAKE_SOURCE_DIR}/bin) install(FILES $<TARGET_PDB_FILE:${target}> DESTINATION ${CMAKE_SOURCE_DIR}/bin)
endif() endif()
if(TARGET SDL2::SDL2)
# Copy SDL2 DLL to binary directory.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
get_property(SDL2_DLL_PATH TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_DEBUG)
else()
get_property(SDL2_DLL_PATH TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_RELEASE)
endif()
if(SDL2_DLL_PATH)
install(FILES ${SDL2_DLL_PATH} DESTINATION ${CMAKE_SOURCE_DIR}/bin)
endif()
endif()
find_program(WINDEPLOYQT_EXE windeployqt HINTS "${QT_BINARY_DIRECTORY}") find_program(WINDEPLOYQT_EXE windeployqt HINTS "${QT_BINARY_DIRECTORY}")
install(CODE "execute_process(COMMAND \"${WINDEPLOYQT_EXE}\" \"${CMAKE_SOURCE_DIR}/bin/$<TARGET_FILE_NAME:${target}>\" --plugindir \"${CMAKE_SOURCE_DIR}/bin/QtPlugins\" --no-compiler-runtime --no-system-d3d-compiler COMMAND_ERROR_IS_FATAL ANY)") install(CODE "execute_process(COMMAND \"${WINDEPLOYQT_EXE}\" \"${CMAKE_SOURCE_DIR}/bin/$<TARGET_FILE_NAME:${target}>\" --plugindir \"${CMAKE_SOURCE_DIR}/bin/QtPlugins\" --no-compiler-runtime --no-system-d3d-compiler COMMAND_ERROR_IS_FATAL ANY)")
install(CODE "file(WRITE \"${CMAKE_SOURCE_DIR}/bin/qt.conf\" \"[Paths]\\nPlugins = ./QtPlugins\")") install(CODE "file(WRITE \"${CMAKE_SOURCE_DIR}/bin/qt.conf\" \"[Paths]\\nPlugins = ./QtPlugins\")")

View File

@ -49,3 +49,17 @@ if(DISABLE_ADVANCE_SIMD)
else() else()
target_sources(core_test PRIVATE ${multi_isa_sources}) target_sources(core_test PRIVATE ${multi_isa_sources})
endif() endif()
if(WIN32 AND TARGET SDL2::SDL2)
# Copy SDL2 DLL to binary directory.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
get_property(SDL2_DLL_PATH TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_DEBUG)
else()
get_property(SDL2_DLL_PATH TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_RELEASE)
endif()
if(SDL2_DLL_PATH)
add_custom_command(TARGET core_test POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory "$<TARGET_FILE_DIR:core_test>"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${SDL2_DLL_PATH}" "$<TARGET_FILE_DIR:core_test>")
endif()
endif()