We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4597

Summary: Provide proper finding capabilities on sdl2-config.cmake
Product: SDL Reporter: Leonardo <leonardo.guilherme>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: alexander.grund, andreas.r.fischl.work, leonardo.guilherme
Version: 2.0.9   
Hardware: x86_64   
OS: Linux   
See Also: https://bugzilla.libsdl.org/show_bug.cgi?id=4116
https://bugzilla.libsdl.org/show_bug.cgi?id=4225
https://bugzilla.libsdl.org/show_bug.cgi?id=2464
Attachments: Makes sdl2-config.cmake find the library instead of using paths produced by autotools
The sdl2-config.cmake replacement

Description Leonardo 2019-04-13 18:50:21 UTC
Created attachment 3749 [details]
Makes sdl2-config.cmake find the library instead of using paths produced by autotools

This is a followup to bug 2464 which added a bare sdl2-config.cmake to be used when the package is built with autotools (which is the case in most Linux distributions).

The generated sdl2-config.cmake is quite outdated in regards to what is the "modern" standard to using CMake, which is to use `target_link_libraries` to resolve both include and linking dependencies. It also misses linking to "mwindows" on MinGW and the .dmg version for Macintosh targets.

I took the FindSDL2.cmake flying around the internets as a starting point (specifically [1]) since it always worked well enough in th past and then made it declare proper IMPORTED cmake targets.

The result is the proposed patch, which I believe fixes bug 4116 and bug 4225.


[1]: https://github.com/tcbrindle/sdl2-cmake-scripts/blob/master/FindSDL2.cmake
Comment 1 Leonardo 2019-04-13 18:53:04 UTC
Created attachment 3750 [details]
The sdl2-config.cmake replacement
Comment 2 alexander.grund 2020-02-07 15:20:18 UTC
This is not a good solution. What you wrote is a Find-Module not a config. A config should be configured to contain the correct paths as per the installation so using paths produced by autotools is fine. You can and should use variables set by configure to set the correct values in the config file.

But you are right: The config should also create an imported target SDL2::SDL2 which has everything set. The values should come from configure (see above)