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

Configure generated sdl2-config.cmake should contain version #3531

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

Configure generated sdl2-config.cmake should contain version #3531

SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

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.10
Reported for operating system, platform: All, All

Comments on the original bug report:

On 2020-02-07 15:43:39 +0000, wrote:

The sdl2-config.cmake generated by configure does not contain the version.

The variables PACKAGE_VERSION (and optionally) SDL2_VERSION should be set there too. Otherwise e.g. find_package(SDL2 2.0.10) will fail as it finds the config but not the version

That is another issue which can be solved by generating it uniformly or use CMake for everything, see https://bugzilla.libsdl.org/show_bug.cgi?id=4116

On 2020-02-14 18:38:21 +0000, Ryan C. Gordon wrote:

This should be fixed by https://hg.libsdl.org/SDL/rev/d62544e5fa7a but let me know if I messed this up, please!

--ryan.

On 2020-02-20 14:06:45 +0000, wrote:

Created attachment 4223
Patch with autogen

Thanks ryan, that was what I meant but I was wrong in how it should look like. Apparently you need a separate version file, see the full description at https://cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html

I took a shot at this myself and additionally created the targets that would be created by the CMake scripts. The resulting files on my system look like this:

sdl2-config.cmake:

sdl2 cmake project-config input for ./configure scripts

set(prefix "/tmp/sdl2")
set(exec_prefix "${prefix}")
set(libdir "${exec_prefix}/lib")
set(SDL2_PREFIX "/tmp/sdl2")
set(SDL2_EXEC_PREFIX "/tmp/sdl2")
set(SDL2_LIBDIR "${exec_prefix}/lib")
set(SDL2_INCLUDE_DIRS "${prefix}/include/SDL2")
set(SDL2_LIBRARIES "-L${SDL2_LIBDIR} -Wl,-rpath,${libdir} -Wl,--enable-new-dtags -lSDL2")
string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)

if(NOT TARGET SDL2::SDL2)

Remove -lSDL2 as that is handled by CMake, note the space at the end so it does not replace e.g. -lSDL2main

This may require "libdir" beeing set (from above)

string(REPLACE "-lSDL2 " "" SDL2_EXTRA_LINK_FLAGS "-Wl,-rpath,${libdir} -Wl,--enable-new-dtags -lSDL2 ")
string(STRIP "${SDL2_EXTRA_LINK_FLAGS}" SDL2_EXTRA_LINK_FLAGS)
string(REPLACE "-lSDL2 " "" SDL2_EXTRA_LINK_FLAGS_STATIC "-Wl,-rpath,${libdir} -Wl,--enable-new-dtags -lSDL2 -Wl,--no-undefined -lm -ldl -lpthread -lrt ")
string(STRIP "${SDL2_EXTRA_LINK_FLAGS_STATIC}" SDL2_EXTRA_LINK_FLAGS_STATIC)

add_library(SDL2::SDL2 SHARED IMPORTED)
set_target_properties(SDL2::SDL2 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${prefix}/include/SDL2"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${exec_prefix}/lib/libSDL2.so"
INTERFACE_LINK_LIBRARIES "${SDL2_EXTRA_LINK_FLAGS}")

add_library(SDL2::SDL2-static STATIC IMPORTED)
set_target_properties(SDL2::SDL2-static PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${prefix}/include/SDL2"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${exec_prefix}/lib/libSDL2.a"
INTERFACE_LINK_LIBRARIES "${SDL2_EXTRA_LINK_FLAGS_STATIC}")

add_library(SDL2::SDL2main STATIC IMPORTED)
set_target_properties(SDL2::SDL2main PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${exec_prefix}/lib/libSDL2main.a")
endif()

sdl2-config-version.cmake:
set(PACKAGE_VERSION "2.0.10")

if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

On 2020-02-20 14:07:21 +0000, wrote:

Created attachment 4224
Patch without autogen changes

On 2020-02-20 14:08:56 +0000, wrote:

Note that the patch(es) were created on top of 2.0.10. Your changes from https://hg.libsdl.org/SDL/rev/d62544e5fa7a may need to be reverted first (not required after this patch as CMake will set SDL2_VERSION and SDL2_VERSION_* variables)

On 2020-02-21 20:53:24 +0000, Ryan C. Gordon wrote:

This patch is now https://hg.libsdl.org/SDL/rev/ef2d5382a887, thanks!

--ryan.

On 2020-02-24 08:30:10 +0000, wrote:

Seems the addition of sdl2-config-version.cmake.in is missing.

I suggest to test-build with autotools and compare the 2 generated files in the installation folder with my example in https://bugzilla.libsdl.org/show_bug.cgi?id=4970#c2

On 2020-03-01 20:38:33 +0000, Sam Lantinga wrote:

I just wanted to confirm that what's in the latest snapshot is correct?
http://www.libsdl.org/tmp/SDL-2.0.zip

Thanks!

On 2020-03-02 09:25:10 +0000, wrote:

Yes I successfully verified SDL-2.0.11-13563 is working with a CMake project. Thanks!

On 2020-03-02 22:53:12 +0000, Sam Lantinga wrote:

Great, thanks!

On 2020-03-15 03:08:36 +0000, Joshua Root wrote:

(In reply to Ryan C. Gordon from comment # 5)

This patch is now https://hg.libsdl.org/SDL/rev/ef2d5382a887, thanks!

This results in an incorrect library suffix being used on macOS (originally reported in macports/macports-ports#6581).

Would you like me to open a new bug for this issue?

On 2020-03-16 09:32:01 +0000, wrote:

Sorry for the wrong suffix. Best would be to use CMAKE_SHARED_LIBRARY_SUFFIX and CMAKE_STATIC_LIBRARY_SUFFIX. But it needs double-checking with the code generating the library names. As I don't know autotools well enough, I'll leave this to someone else. But my bet would be that using CMAKE_*_LIBRARY_SUFFIX solves the problem already.

On 2020-03-16 19:15:56 +0000, Sam Lantinga wrote:

Ryan, this is a regression, can you look at this ASAP?

On 2020-03-16 19:16:33 +0000, Sam Lantinga wrote:

Actually, Joshua, can you open a new bug for the regression?

Thanks!

On 2020-03-17 02:23:32 +0000, Joshua Root wrote:

(In reply to Sam Lantinga from comment # 13)

Actually, Joshua, can you open a new bug for the regression?
Done: bug 5039.

On 2020-03-17 07:24:46 +0000, wrote:

FWIW: This is NOT a regression as only the new feature (the target) is affected. The old Variables which existed before are untouched

But yes should be changed ASAP

smcv added a commit to smcv/SDL_ttf that referenced this issue May 6, 2022
Ubuntu 20.04's SDL was built with Autotools and is older than
libsdl-org/SDL#3531, so it doesn't define
the SDL2::SDL2 target.

Signed-off-by: Simon McVittie <smcv@collabora.com>
sezero pushed a commit to libsdl-org/SDL_ttf that referenced this issue May 6, 2022
Ubuntu 20.04's SDL was built with Autotools and is older than
libsdl-org/SDL#3531, so it doesn't define
the SDL2::SDL2 target.

Signed-off-by: Simon McVittie <smcv@collabora.com>
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

1 participant