From e72f634fba2b7c8a8b3f5e567ea9e2d91e2321d3 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 16 May 2024 23:05:44 +0200 Subject: [PATCH] [client,sdl] automatically use detected SDL * Automatically enable detected SDL version * Abort if no SDL version is detected --- client/SDL/CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/client/SDL/CMakeLists.txt b/client/SDL/CMakeLists.txt index 2c5e4631f..2965544b3 100644 --- a/client/SDL/CMakeLists.txt +++ b/client/SDL/CMakeLists.txt @@ -61,20 +61,26 @@ endif() include(CMakeDependentOption) +find_package(SDL2) +find_package(SDL3) + cmake_dependent_option(WITH_CLIENT_SDL_VERSIONED "append sdl version to client binaries" OFF WITH_CLIENT_SDL OFF) -cmake_dependent_option(WITH_CLIENT_SDL2 "[experimental] build experimental SDL2 client" ON WITH_CLIENT_SDL OFF) -cmake_dependent_option(WITH_CLIENT_SDL3 "[experimental] build experimental SDL3 client" OFF WITH_CLIENT_SDL OFF) +cmake_dependent_option(WITH_CLIENT_SDL2 "[experimental] build experimental SDL2 client" ${SDL2_FOUND} WITH_CLIENT_SDL OFF) +cmake_dependent_option(WITH_CLIENT_SDL3 "[experimental] build experimental SDL3 client" ${SDL3_FOUND} WITH_CLIENT_SDL OFF) if (WITH_CLIENT_SDL2 AND WITH_CLIENT_SDL3) message("Building both, SDL2 and SDL3 clients, forcing WITH_CLIENT_SDL_VERSIONED=ON") set(WITH_CLIENT_SDL_VERSIONED ON) endif() +if (NOT SDL2_FOUND AND NOT SDL3_FOUND) + message(FATAL_ERROR "No SDL library detected, giving up. Install SDL2 or SDL3 development package to fix") +endif() + add_subdirectory(common) include_directories(common) if (WITH_CLIENT_SDL2) - find_package(SDL2) if (SDL2_FOUND) add_subdirectory(SDL2) else() @@ -83,7 +89,6 @@ if (WITH_CLIENT_SDL2) endif() if (WITH_CLIENT_SDL3) - find_package(SDL3) if (SDL3_FOUND) add_subdirectory(SDL3) else()