Skip to content

[sdl2] don't specify -Wl,--no-undefined on INTERFACE_LINK_LIBRARIES #14743

@JesseFarebro

Description

@JesseFarebro

Is your feature request related to a problem? Please describe.
When building SDL2 dynamically on Linux & macOS with a custom triplet SDL specifies -Wl,--no-undefined on INTERFACE_LINK_INTERFACE_LIBRARIES. This will get propagated to the downstream target causing undefined references even in cases where this should be allowed, e..g, libpython references from Pybind11.

Proposed solution
Remove -Wl,--no-undefined from SDL2Targets-*.cmake (through some patch presumably, I haven't investigated this much). Other platforms seem to build SDL2 with autogen which seems to use a completely different CMake config (sdl2-config.cmake in the SDL2 repo). I'm not quite sure why there's two different CMake configs, i.e., one generated from CMakeLists and one from the autogen build.

Describe alternatives you've considered
You can manually specify set_target_properties(SDL2::SDL2 IMPORTED_LINK_INTERFACE_LIBRARIES ...) after find_package.

Additional context
I'm a little confused why this linker flag would be provided in the INTERFACE_ prop. Shouldn't this be up to library consumer to decide how they want to handle undefined symbols? The property is called _LINK_LIBRARIES and this flag definitely isn't a library. I can't seem to find any other examples of SDL2 being packaged using the CMakeLists build config. Homebrew and Linux distros seem to use the autogen based config and hence provide the sdl2-config.cmake file which doesn't include this linker flag.

Related issue @ SDL2: https://bugzilla.libsdl.org/show_bug.cgi?id=5249#c0

Metadata

Metadata

Assignees

Labels

category:port-bugThe issue is with a library, which is something the port should already support

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions