diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2021-05-16 10:05:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-16 10:05:42 +0200 |
commit | 9edfd88a8a4244848ae564749d591903699f9946 (patch) | |
tree | 18bd4e2942e316dbc6433f3e29e893ccda190a98 | |
parent | Merge pull request #6316 from ameerj/title-fix (diff) | |
parent | Only build SDL2 subsystems that we use (diff) | |
download | yuzu-9edfd88a8a4244848ae564749d591903699f9946.tar yuzu-9edfd88a8a4244848ae564749d591903699f9946.tar.gz yuzu-9edfd88a8a4244848ae564749d591903699f9946.tar.bz2 yuzu-9edfd88a8a4244848ae564749d591903699f9946.tar.lz yuzu-9edfd88a8a4244848ae564749d591903699f9946.tar.xz yuzu-9edfd88a8a4244848ae564749d591903699f9946.tar.zst yuzu-9edfd88a8a4244848ae564749d591903699f9946.zip |
-rw-r--r-- | CMakeLists.txt | 30 | ||||
-rw-r--r-- | externals/CMakeLists.txt | 12 |
2 files changed, 30 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c8e9ebf8a..3faa2b5ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ project(yuzu) # OFF by default, but if ENABLE_SDL2 and MSVC are true then ON option(ENABLE_SDL2 "Enable the SDL2 frontend" ON) CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" ON "ENABLE_SDL2;MSVC" OFF) +# On Linux system SDL2 is likely to be lacking HIDAPI support which have drawbacks but is needed for SDL motion +CMAKE_DEPENDENT_OPTION(YUZU_ALLOW_SYSTEM_SDL2 "Try using system SDL2 before fallling back to one from externals" NOT UNIX "ENABLE_SDL2" OFF) option(ENABLE_QT "Enable the Qt frontend" ON) option(ENABLE_QT_TRANSLATION "Enable translations for the Qt frontend" OFF) @@ -292,20 +294,24 @@ if (ENABLE_SDL2) target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARY}") target_include_directories(SDL2 INTERFACE "${SDL2_INCLUDE_DIR}") else() - find_package(SDL2 2.0.15 QUIET) - - 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") - set(SDL2_LIBRARIES "SDL2::SDL2") + if (YUZU_ALLOW_SYSTEM_SDL2) + find_package(SDL2 2.0.15 QUIET) + + 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") + set(SDL2_LIBRARIES "SDL2::SDL2") + endif() + + include_directories(SYSTEM ${SDL2_INCLUDE_DIRS}) + add_library(SDL2 INTERFACE) + target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARIES}") + else() + message(STATUS "SDL2 2.0.15 or newer not found, falling back to externals.") endif() - - include_directories(SYSTEM ${SDL2_INCLUDE_DIRS}) - add_library(SDL2 INTERFACE) - target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARIES}") else() - message(STATUS "SDL2 2.0.15 or newer not found, falling back to externals.") + message(STATUS "Using SDL2 from externals.") endif() endif() endif() diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index e280e53d7..fe1c088ca 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -47,8 +47,20 @@ target_include_directories(unicorn-headers INTERFACE ./unicorn/include) # SDL2 if (NOT SDL2_FOUND AND ENABLE_SDL2) + # Yuzu itself needs: Events Joystick Haptic Sensor Timers + # Yuzu-cmd also needs: Video (depends on Loadso/Dlopen) + set(SDL_UNUSED_SUBSYSTEMS + Atomic Audio Render Power Threads + File CPUinfo Filesystem Locale) + foreach(_SUB ${SDL_UNUSED_SUBSYSTEMS}) + string(TOUPPER ${_SUB} _OPT) + option(SDL_${_OPT} "" OFF) + endforeach() + set(SDL_STATIC ON) set(SDL_SHARED OFF) + option(HIDAPI "" ON) + add_subdirectory(SDL EXCLUDE_FROM_ALL) add_library(SDL2 ALIAS SDL2-static) endif() |