Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide proper finding capabilities on sdl2-config.cmake #3238

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 3 comments
Closed

Provide proper finding capabilities on sdl2-config.cmake #3238

SDLBugzilla opened this issue Feb 11, 2021 · 3 comments
Assignees
Milestone

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.9
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2019-04-13 18:50:21 +0000, Leonardo wrote:

Created attachment 3749
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.

On 2019-04-13 18:53:04 +0000, Leonardo wrote:

Created attachment 3750
The sdl2-config.cmake replacement

On 2020-02-07 15:20:18 +0000, wrote:

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)

@glebm
Copy link
Contributor

glebm commented Dec 4, 2021

In buildroot we use the following workaround for autotools-built SDL2:

https://github.com/buildroot/buildroot/blob/99d2826e039858b749504cb53e713e8b53664b39/package/sdl2/sdl2.mk#L25-L35

It changes sdl2-config.cmake paths to be relative to sdl2-config.cmake location instead of /usr.

@slouken slouken removed the bug label May 11, 2022
@slouken slouken added this to the 2.24.0 milestone May 24, 2022
@madebr
Copy link
Contributor

madebr commented Jun 15, 2022

The sdl2-config.cmake file, generated and installed by the autotools build scripts are currently 100% functionally equivalent with the ones installed by CMakeLists.txt (and vice versa).

Also, the installedsdl2-config.cmake script + sdl2-config bash script are fully relocatable.
Which means you can move the installed sdl2 folder to whatever location you want and it keeps working.
That's one thing less buildroot has to patch.

@madebr madebr closed this as completed Jun 15, 2022
@glebm
Copy link
Contributor

glebm commented Jun 15, 2022

Thanks @madebr!

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

No branches or pull requests

4 participants