From 73a7d7e5dbd69a40312225d8fc8c508a67795361 Mon Sep 17 00:00:00 2001 From: Max Heimbrock <43608204+MaxHeimbrock@users.noreply.github.com> Date: Mon, 10 Aug 2026 13:50:53 +0200 Subject: [PATCH] fix: avoid SDL3 target conflict when a system SDL3 is installed find_package(SDL3) was followed by a check of INTERFACE_INCLUDE_DIRECTORIES on SDL3::SDL3 to decide whether the found package is usable. In the standard SDL3 package layout, SDL3::SDL3 is an alias of SDL3::SDL3-shared, which gets its include dirs transitively via SDL3::Headers instead of carrying them itself. The check therefore came back empty on e.g. Homebrew installs, SDL3 was fetched from source anyway, and its add_library(SDL3::Headers ALIAS ...) collided with the already-imported target: CMake Error: add_library cannot create ALIAS target "SDL3::Headers" because another target with the same name already exists. Trust the find_package result instead: fetch only when no SDL3::SDL3 target exists. Co-Authored-By: Claude Fable 5 --- cmake/ExampleDeps.cmake | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/cmake/ExampleDeps.cmake b/cmake/ExampleDeps.cmake index 907fe1b..1e6ee2e 100644 --- a/cmake/ExampleDeps.cmake +++ b/cmake/ExampleDeps.cmake @@ -10,21 +10,10 @@ if(NOT TARGET nlohmann_json::nlohmann_json) endif() find_package(SDL3 CONFIG QUIET) -set(_need_sdl3_fetch TRUE) -if(TARGET SDL3::SDL3) - get_target_property(_sdl3_include_dirs SDL3::SDL3 INTERFACE_INCLUDE_DIRECTORIES) - if(_sdl3_include_dirs) - set(_need_sdl3_fetch FALSE) - endif() -endif() - -if(_need_sdl3_fetch) +if(NOT TARGET SDL3::SDL3) FetchContent_Declare( SDL3 URL https://github.com/libsdl-org/SDL/releases/download/release-3.2.26/SDL3-3.2.26.tar.gz ) FetchContent_MakeAvailable(SDL3) endif() - -unset(_need_sdl3_fetch) -unset(_sdl3_include_dirs)