From f4eb8bc6447f44a333b31717132c7b25c6a7ef4a Mon Sep 17 00:00:00 2001 From: Nadia Holmquist Pedersen Date: Tue, 12 Nov 2024 16:49:10 +0100 Subject: [PATCH] cmake: Add a USE_SYSTEM_SDL2 option --- CMakeLists.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74fafc04c..051831e04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ option(ENABLE_HTTP_SERVER "Enable HTTP server. Used for Discord bot support" OFF option(ENABLE_DISCORD_RPC "Compile with Discord RPC support (disabled by default)" ON) option(ENABLE_LUAJIT "Enable scripting with the Lua programming language" ON) option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF) +option(USE_SYSTEM_SDL2 "Use the system's SDL2 package" OFF) option(ENABLE_GIT_VERSIONING "Enables querying git for the emulator version" ON) option(BUILD_HYDRA_CORE "Build a Hydra core" OFF) option(BUILD_LIBRETRO_CORE "Build a Libretro core" OFF) @@ -145,18 +146,22 @@ if(ENABLE_DISCORD_RPC AND NOT ANDROID) include_directories(third_party/discord-rpc/include) endif() -set(SDL_STATIC ON CACHE BOOL "" FORCE) -set(SDL_SHARED OFF CACHE BOOL "" FORCE) -set(SDL_TEST OFF CACHE BOOL "" FORCE) if (NOT ANDROID) - add_subdirectory(third_party/SDL2) - target_link_libraries(AlberCore PUBLIC SDL2-static) + if (USE_SYSTEM_SDL2) + find_package(SDL2 CONFIG REQUIRED) + target_link_libraries(AlberCore PUBLIC SDL2::SDL2) + else() + set(SDL_STATIC ON CACHE BOOL "" FORCE) + set(SDL_SHARED OFF CACHE BOOL "" FORCE) + set(SDL_TEST OFF CACHE BOOL "" FORCE) + add_subdirectory(third_party/SDL2) + target_link_libraries(AlberCore PUBLIC SDL2-static) + endif() endif() add_subdirectory(third_party/fmt) add_subdirectory(third_party/toml11) -include_directories(${SDL2_INCLUDE_DIR}) include_directories(third_party/toml11) include_directories(third_party/glm) include_directories(third_party/renderdoc)