From f25582833aa5d9cc8e540c217cf301eab9e607e7 Mon Sep 17 00:00:00 2001 From: crueter Date: Wed, 25 Feb 2026 02:49:47 +0100 Subject: [PATCH] [cmake] Start requiring SDL2 (#3632) Closes #3466 Like said in the issue and the OpenSSL equivalent, disabling SDL2 on desktop is just not something we want to do. It's not worth the added burden of supporting the n+1'th matrix. Signed-off-by: crueter Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3632 Reviewed-by: CamilleLaVey Reviewed-by: MaranBr --- CMakeLists.txt | 13 ++++--------- externals/CMakeLists.txt | 3 +-- src/CMakeLists.txt | 2 +- src/android/app/build.gradle.kts | 1 - src/audio_core/CMakeLists.txt | 31 +++++++++++-------------------- src/input_common/CMakeLists.txt | 26 ++++++++++++-------------- src/yuzu/CMakeLists.txt | 7 +------ src/yuzu/main_window.cpp | 8 +++----- 8 files changed, 33 insertions(+), 58 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64e847465e..11d97724de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,6 @@ if (YUZU_STATIC_ROOM) # disable e v e r y t h i n g set(ENABLE_QT OFF) - set(ENABLE_SDL2 OFF) set(YUZU_CMD OFF) set(ENABLE_CUBEB OFF) set(ENABLE_UPDATE_CHECKER OFF) @@ -171,13 +170,9 @@ if (MSVC AND NOT CXX_CLANG) set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} /W3 /WX-") endif() -# Set bundled sdl2/qt as dependent options. -# On Linux system SDL2 is likely to be lacking HIDAPI support which have drawbacks but is needed for SDL motion -cmake_dependent_option(ENABLE_SDL2 "Enable the SDL2 frontend" ON "NOT ANDROID" OFF) - # TODO(crueter): Cleanup, each dep that has a bundled option should allow to choose between bundled, external, system -cmake_dependent_option(YUZU_USE_EXTERNAL_SDL2 "Build SDL2 from external source" OFF "ENABLE_SDL2;NOT MSVC" OFF) -cmake_dependent_option(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 build" "${MSVC}" "ENABLE_SDL2" OFF) +cmake_dependent_option(YUZU_USE_EXTERNAL_SDL2 "Build SDL2 from external source" OFF "NOT MSVC;NOT ANDROID" OFF) +cmake_dependent_option(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 build" "${MSVC}" "NOT ANDROID" OFF) option(ENABLE_CUBEB "Enables the cubeb audio backend" ON) @@ -220,7 +215,7 @@ option(NIGHTLY_BUILD "Use Nightly qualifiers in the update checker and build met cmake_dependent_option(YUZU_ROOM "Enable dedicated room functionality" ON "NOT ANDROID" OFF) cmake_dependent_option(YUZU_ROOM_STANDALONE "Enable standalone room executable" ON "YUZU_ROOM" OFF) -cmake_dependent_option(YUZU_CMD "Compile the eden-cli executable" ON "ENABLE_SDL2;NOT ANDROID" OFF) +cmake_dependent_option(YUZU_CMD "Compile the eden-cli executable" ON "NOT ANDROID" OFF) cmake_dependent_option(YUZU_CRASH_DUMPS "Compile crash dump (Minidump) support" OFF "WIN32 OR PLATFORM_LINUX" OFF) @@ -544,7 +539,7 @@ if (NOT YUZU_STATIC_ROOM) find_package(oaknut) endif() - if (ENABLE_SDL2) + if (NOT ANDROID) find_package(SDL2) endif() diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index acec7debe5..7b4c481ba5 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -133,8 +133,7 @@ if(ENABLE_CUBEB) endif() endif() -# find SDL2 exports a bunch of variables that are needed, so its easier to do this outside of the YUZU_find_package -if (ENABLE_SDL2) +if (NOT ANDROID) if (YUZU_USE_EXTERNAL_SDL2) message(STATUS "Using SDL2 from externals.") if (NOT WIN32) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 998c73543a..21affffb6b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -235,7 +235,7 @@ if (YUZU_TESTS) add_subdirectory(tests) endif() -if (ENABLE_SDL2 AND YUZU_CMD) +if (YUZU_CMD) add_subdirectory(yuzu_cmd) set_target_properties(yuzu-cmd PROPERTIES OUTPUT_NAME "eden-cli") endif() diff --git a/src/android/app/build.gradle.kts b/src/android/app/build.gradle.kts index 06c35669ce..622ae53a77 100644 --- a/src/android/app/build.gradle.kts +++ b/src/android/app/build.gradle.kts @@ -79,7 +79,6 @@ android { arguments.addAll( listOf( "-DENABLE_QT=0", // Don't use QT - "-DENABLE_SDL2=0", // Don't use SDL "-DENABLE_WEB_SERVICE=1", // Enable web service "-DENABLE_OPENSSL=ON", "-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index 90ee460b55..4f8cc7d1ca 100644 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2018 yuzu Emulator Project @@ -231,38 +231,29 @@ endif() target_include_directories(audio_core PRIVATE ${OPUS_INCLUDE_DIRS}) target_link_libraries(audio_core PUBLIC common core Opus::opus) -# what? -# if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64) -# target_link_libraries(audio_core PRIVATE dynarmic::dynarmic) -# endif() - if (ENABLE_CUBEB) target_sources(audio_core PRIVATE sink/cubeb_sink.cpp - sink/cubeb_sink.h - ) + sink/cubeb_sink.h) target_link_libraries(audio_core PRIVATE cubeb::cubeb) target_compile_definitions(audio_core PRIVATE HAVE_CUBEB=1) endif() -if (ENABLE_SDL2) - target_sources(audio_core PRIVATE - sink/sdl2_sink.cpp - sink/sdl2_sink.h - ) - - target_link_libraries(audio_core PRIVATE SDL2::SDL2) - target_compile_definitions(audio_core PRIVATE HAVE_SDL2) -endif() - if(ANDROID) target_sources(audio_core PRIVATE sink/oboe_sink.cpp - sink/oboe_sink.h - ) + sink/oboe_sink.h) + target_link_libraries(audio_core PRIVATE oboe) target_compile_definitions(audio_core PUBLIC HAVE_OBOE) +else() + target_sources(audio_core PRIVATE + sink/sdl2_sink.cpp + sink/sdl2_sink.h) + + target_link_libraries(audio_core PRIVATE SDL2::SDL2) + target_compile_definitions(audio_core PRIVATE HAVE_SDL2) endif() create_target_directory_groups(audio_core) diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index 30ccd7e8c1..ef1308b1d0 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2018 yuzu Emulator Project @@ -49,7 +49,13 @@ else() ) endif() -if (ENABLE_SDL2) +if (ANDROID) + target_sources(input_common PRIVATE + drivers/android.cpp + drivers/android.h) + + target_link_libraries(input_common PRIVATE android) +else() target_sources(input_common PRIVATE drivers/joycon.cpp drivers/joycon.h @@ -73,8 +79,8 @@ if (ENABLE_SDL2) helpers/joycon_protocol/ringcon.cpp helpers/joycon_protocol/ringcon.h helpers/joycon_protocol/rumble.cpp - helpers/joycon_protocol/rumble.h - ) + helpers/joycon_protocol/rumble.h) + target_link_libraries(input_common PRIVATE SDL2::SDL2) target_compile_definitions(input_common PRIVATE HAVE_SDL2) endif() @@ -82,19 +88,11 @@ endif() if (ENABLE_LIBUSB) target_sources(input_common PRIVATE drivers/gc_adapter.cpp - drivers/gc_adapter.h - ) + drivers/gc_adapter.h) + target_link_libraries(input_common PRIVATE libusb::usb) target_compile_definitions(input_common PRIVATE ENABLE_LIBUSB) endif() create_target_directory_groups(input_common) target_link_libraries(input_common PUBLIC hid_core PRIVATE common Boost::headers) - -if (ANDROID) - target_sources(input_common PRIVATE - drivers/android.cpp - drivers/android.h - ) - target_link_libraries(input_common PRIVATE android) -endif() diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 725639a8fe..c85d43235a 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -431,11 +431,6 @@ if (WIN32 AND NOT YUZU_USE_BUNDLED_QT) add_custom_command(TARGET yuzu POST_BUILD COMMAND ${WINDEPLOYQT_EXECUTABLE} "${YUZU_EXE_DIR}/eden.exe" --dir "${YUZU_EXE_DIR}" --libdir "${YUZU_EXE_DIR}" --plugindir "${YUZU_EXE_DIR}/plugins" --no-compiler-runtime --no-opengl-sw --no-system-d3d-compiler --no-translations --verbose 0) endif() -if (ENABLE_SDL2) - target_link_libraries(yuzu PRIVATE SDL2::SDL2) - target_compile_definitions(yuzu PRIVATE HAVE_SDL2) -endif() - if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64) target_link_libraries(yuzu PRIVATE dynarmic::dynarmic) endif() @@ -454,6 +449,6 @@ if (NOT MSVC AND (APPLE OR NOT YUZU_STATIC_BUILD)) endif() # Remember that the linker is incredibly stupid. -target_link_libraries(yuzu PRIVATE OpenSSL::SSL OpenSSL::Crypto) +target_link_libraries(yuzu PRIVATE OpenSSL::SSL OpenSSL::Crypto SDL2::SDL2) create_target_directory_groups(yuzu) diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp index e1a94632f9..e19f2def95 100644 --- a/src/yuzu/main_window.cpp +++ b/src/yuzu/main_window.cpp @@ -149,9 +149,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include "video_core/renderer_base.h" #include "video_core/shader_notify.h" -#ifdef HAVE_SDL2 #include -#endif #include @@ -602,7 +600,7 @@ MainWindow::MainWindow(bool has_broken_vulkan) VkDeviceInfo::PopulateRecords(vk_device_records, this->window()->windowHandle()); } -#if defined(HAVE_SDL2) && !defined(_WIN32) +#if !defined(_WIN32) SDL_InitSubSystem(SDL_INIT_VIDEO); // Set a screensaver inhibition reason string. Currently passed to DBus by SDL and visible to @@ -1881,7 +1879,7 @@ void MainWindow::OnSigInterruptNotifierActivated() { void MainWindow::PreventOSSleep() { #ifdef _WIN32 SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED); -#elif defined(HAVE_SDL2) +#else SDL_DisableScreenSaver(); #endif } @@ -1889,7 +1887,7 @@ void MainWindow::PreventOSSleep() { void MainWindow::AllowOSSleep() { #ifdef _WIN32 SetThreadExecutionState(ES_CONTINUOUS); -#elif defined(HAVE_SDL2) +#else SDL_EnableScreenSaver(); #endif }