fix: avoid SDL3 target conflict when a system SDL3 is installed - #22
Merged
Conversation
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>
MaxHeimbrock
requested review from
alan-george-lk,
stephen-derosa and
xianshijing-lk
as code owners
August 10, 2026 11:53
stephen-derosa
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Configuring the example collection fails on any machine with a system SDL3 install (e.g. Homebrew):
ExampleDeps.cmakecallsfind_package(SDL3 CONFIG QUIET)and then checksINTERFACE_INCLUDE_DIRECTORIESonSDL3::SDL3to decide whether the found package is usable. In the standard SDL3 package layout,SDL3::SDL3is an alias ofSDL3::SDL3-shared, which gets its include dirs transitively viaSDL3::Headersrather than carrying them itself. The property check therefore comes back empty, SDL3 gets fetched from source anyway, and the source build'sadd_library(SDL3::Headers ALIAS ...)collides with the target already imported from the system package.Fix
Trust the
find_packageresult: fetch SDL3 from source only when noSDL3::SDL3target exists.Testing
🤖 Generated with Claude Code