From de69a5266fde93a793fc3664db205ec7bad3e9a9 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sat, 17 Apr 2021 23:35:13 -0400 Subject: [PATCH 1/2] cmake: Use SDL 2.0.14 and fix CMake scope issue Forces using SDL 2.0.14. Upgrades the SDL external to that version. Adds a message when switching to the external. Fixes an error where input_common only links to SDL when SDL2_FOUND is set, but externals/CMakeLists cannot set that variable to the required scope. Switch to using ENABLE_SDL2, which we can use since we now include the SDL source. --- CMakeLists.txt | 8 ++++---- externals/CMakeLists.txt | 3 +-- externals/SDL | 2 +- src/input_common/CMakeLists.txt | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e208715d7..2c1c3d560 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,9 +274,9 @@ if (ENABLE_SDL2) target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARY}") target_include_directories(SDL2 INTERFACE "${SDL2_INCLUDE_DIR}") else() - find_package(SDL2 2.0.12) + find_package(SDL2 2.0.14) - if(SDL2_FOUND) + if (SDL2_FOUND) # Some installations don't set SDL2_LIBRARIES if("${SDL2_LIBRARIES}" STREQUAL "") message(WARNING "SDL2_LIBRARIES wasn't set, manually setting to SDL2::SDL2") @@ -286,10 +286,10 @@ if (ENABLE_SDL2) include_directories(SYSTEM ${SDL2_INCLUDE_DIRS}) add_library(SDL2 INTERFACE) target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARIES}") + else() + message(STATUS "SDL2 2.0.14 or newer not found, falling back to externals.") endif() endif() -else() - set(SDL2_FOUND NO) endif() # Install any missing dependencies with conan install diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 6e4591b4e..e044d9730 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -46,8 +46,7 @@ add_library(unicorn-headers INTERFACE) target_include_directories(unicorn-headers INTERFACE ./unicorn/include) # SDL2 -if (NOT SDL2_FOUND) - set(SDL2_FOUND YES) +if (NOT SDL2_FOUND AND ENABLE_SDL2) add_subdirectory(SDL EXCLUDE_FROM_ALL) endif() diff --git a/externals/SDL b/externals/SDL index 983bbf9ef..4cd981609 160000 --- a/externals/SDL +++ b/externals/SDL @@ -1 +1 @@ -Subproject commit 983bbf9ef3e572a073a6f5877faf1c0b4803527c +Subproject commit 4cd981609b50ed273d80c635c1ca4c1e5518fb21 diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index c3cfe7efc..de53e1fda 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt @@ -62,7 +62,7 @@ else() ) endif() -if(SDL2_FOUND) +if (ENABLE_SDL2) target_sources(input_common PRIVATE sdl/sdl_impl.cpp sdl/sdl_impl.h From f973274b99d6683d257d77b5d2fd1994853ec3a7 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 18 Apr 2021 00:40:31 -0400 Subject: [PATCH 2/2] general: Ignore implicit-fallthrough for SDL.h SDL 2.0.14 introduces an incompatibility with Clang, causing it to trigger -Wimplicit-fallthrough even though it is marked. Ignore it for now, with a comment mentioning why this is needed. --- src/input_common/sdl/sdl_impl.cpp | 10 ++++++++++ src/yuzu_cmd/config.cpp | 10 ++++++++++ src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 9 +++++++++ src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp | 10 ++++++++++ src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp | 8 ++++++++ 5 files changed, 47 insertions(+) diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 9418e78fa..f682a6db4 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp @@ -17,7 +17,17 @@ #include #include #include + +// Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wimplicit-fallthrough" +#endif #include +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #include "common/logging/log.h" #include "common/param_package.h" #include "common/settings_input.h" diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 2f984d1b8..7e1d5f379 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp @@ -4,7 +4,17 @@ #include #include + +// Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wimplicit-fallthrough" +#endif #include +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #include #include "common/file_util.h" #include "common/logging/log.h" diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index ce8b7c218..3bb555a6b 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp @@ -2,7 +2,16 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +// Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wimplicit-fallthrough" +#endif #include +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #include "common/logging/log.h" #include "common/scm_rev.h" #include "core/core.h" diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp index a765fa7b3..3c49a300b 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp @@ -5,8 +5,18 @@ #include #include #include + #define SDL_MAIN_HANDLED +// Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wimplicit-fallthrough" +#endif #include +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #include #include #include "common/assert.h" diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp index dfd53e285..3401ad4b4 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp @@ -16,7 +16,15 @@ #include "yuzu_cmd/emu_window/emu_window_sdl2_vk.h" // Include these late to avoid polluting everything with Xlib macros +// Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wimplicit-fallthrough" +#endif #include +#ifdef __clang__ +#pragma clang diagnostic pop +#endif #include EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem)