From 3567d8913f5b710cb3e138ef16cbaff1f452b33b Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 19 Jul 2023 23:09:04 +1000 Subject: [PATCH] CMake: Use dynamic SDL2 on all platforms --- .../scripts/linux/build-dependencies-qt.sh | 4 ++-- .../linux/flatpak/modules/20-sdl2.json | 4 ++-- .../scripts/macos/build-dependencies.sh | 4 ++-- cmake/BuildParameters.cmake | 1 - cmake/SearchForStuff.cmake | 10 +++------ pcsx2/CMakeLists.txt | 22 ++++++++++++------- tests/ctest/core/CMakeLists.txt | 14 ++++++++++++ 7 files changed, 37 insertions(+), 22 deletions(-) diff --git a/.github/workflows/scripts/linux/build-dependencies-qt.sh b/.github/workflows/scripts/linux/build-dependencies-qt.sh index 7e46806c64..75aa07f5ce 100755 --- a/.github/workflows/scripts/linux/build-dependencies-qt.sh +++ b/.github/workflows/scripts/linux/build-dependencies-qt.sh @@ -4,7 +4,7 @@ set -e INSTALLDIR="$HOME/deps" NPROCS="$(getconf _NPROCESSORS_ONLN)" -SDL=SDL2-2.28.1 +SDL=SDL2-2.28.2 QT=6.5.2 LIBBACKTRACE=ad106d5fdd5d960bd33fae1c48a351af567fd075 @@ -12,7 +12,7 @@ mkdir -p deps-build cd deps-build cat > SHASUMS < SHASUMS < DESTINATION ${CMAKE_SOURCE_DIR}/bin) 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}") install(CODE "execute_process(COMMAND \"${WINDEPLOYQT_EXE}\" \"${CMAKE_SOURCE_DIR}/bin/$\" --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\")") diff --git a/tests/ctest/core/CMakeLists.txt b/tests/ctest/core/CMakeLists.txt index cb8902845b..7558cc98ba 100644 --- a/tests/ctest/core/CMakeLists.txt +++ b/tests/ctest/core/CMakeLists.txt @@ -49,3 +49,17 @@ if(DISABLE_ADVANCE_SIMD) else() target_sources(core_test PRIVATE ${multi_isa_sources}) 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 "$" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${SDL2_DLL_PATH}" "$") + endif() +endif()