Skip to content

fix: avoid SDL3 target conflict when a system SDL3 is installed - #22

Merged
stephen-derosa merged 1 commit into
mainfrom
max/fix-sdl3-target-conflict
Aug 10, 2026
Merged

fix: avoid SDL3 target conflict when a system SDL3 is installed#22
stephen-derosa merged 1 commit into
mainfrom
max/fix-sdl3-target-conflict

Conversation

@MaxHeimbrock

Copy link
Copy Markdown
Contributor

Problem

Configuring the example collection fails on any machine with a system SDL3 install (e.g. Homebrew):

CMake Error at build/_deps/sdl3-src/CMakeLists.txt:3364 (add_library):
  add_library cannot create ALIAS target "SDL3::Headers" because another
  target with the same name already exists.

ExampleDeps.cmake calls find_package(SDL3 CONFIG QUIET) and then checks 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 rather than carrying them itself. The property check therefore comes back empty, SDL3 gets fetched from source anyway, and the source build's add_library(SDL3::Headers ALIAS ...) collides with the target already imported from the system package.

Fix

Trust the find_package result: fetch SDL3 from source only when no SDL3::SDL3 target exists.

Testing

  • Reproduced the configure failure on macOS with Homebrew SDL3 3.4.10 installed.
  • With this fix, configure succeeds using the system SDL3 (no source fetch) and the examples build and link against it.

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
@stephen-derosa
stephen-derosa merged commit 707239a into main Aug 10, 2026
8 checks passed
@stephen-derosa
stephen-derosa deleted the max/fix-sdl3-target-conflict branch August 10, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants