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

Trailing whitespace in SDL2_LIBRARIES causes CMAKE error CMP0004 #2131

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

Trailing whitespace in SDL2_LIBRARIES causes CMAKE error CMP0004 #2131

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.4
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2016-03-20 23:36:27 +0000, James Hogan wrote:

When SDL2_LIBRARIES from sdl2-config.cmake is used directly in target_link_libraries, e.g.

find_package(SDL2 REQUIRED)
add_library(mylib STATIC lib.c)
target_link_libraries(mylib ${SDL2_LIBRARIES})

Whitespace at end of SDL2_LIBRARIES causes CMake errors like below:
CMake Error at CMakeLists.txt:8 (add_library):
Target "mylib" links to item "-L/usr/lib64 -lSDL2 " which has leading
or trailing whitespace. This is now an error according to policy CMP0004.

My /usr/lib64/cmake/SDL2/sdl2-config.cmake looks like this (this is Gentoo Linux, from media-libs/libsdl2-2.0.4):

sdl2 cmake project-config input for ./configure scripts

set(prefix "/usr")
set(exec_prefix "${prefix}")
set(libdir "/usr/lib64")
set(SDL2_PREFIX "/usr")
set(SDL2_EXEC_PREFIX "/usr")
set(SDL2_LIBDIR "/usr/lib64")
set(SDL2_INCLUDE_DIRS "${prefix}/include/SDL2")
set(SDL2_LIBRARIES "-L${SDL2_LIBDIR} -lSDL2 ")

You can see the trailing whitespace there. I presume this is due to configure having:
SDL_LIBS="-lSDL2 $BASE_LDFLAGS"

and BASE_LDFLAGS being empty

On 2016-04-29 10:49:52 +0000, wrote:

This has also been reported to Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=822210

There are a couple of tentative patches attached there, but not very well tested or very elegant, or robust; feel free to grab them from there and play.

I will try to remember to attach them here when they are more tested or if we decide to apply them.

On 2016-05-19 11:06:27 +0000, wrote:

Created attachment 2457
bug_822210_fix_sdl2-config.cmake_whitespace.patch

Patch created in Debian to address this issue

On 2016-08-14 06:00:15 +0000, Max wrote:

Will this patch make it into the next SDL release (2.0.5)? I'm not familiar with the bug lifecycle in the SDL2 ecosystem.

In my case, OSX Yosemite, SDL2 (2.0.4), when installed from brew, wont work with CMake 3.6 without plumbing into the sdl-config.cmake in the brew Cellar and removing the trailing spaces manually. As previously stated in this thread the patches recommended in the debian thread look kind of messy but the string(STRIP) command in your patch attachment seems like a safe and risk-free cross-platform solution to me.

On 2016-11-01 18:48:12 +0000, wrote:

With this applied in a commit included 2.0.5 [1], I think that this bug can be closed.

Minor nitpick: The patch is from me / Debian, not Ubuntu, and it was already attached to this bug report many months ago ;-)

[1] https://hg.libsdl.org/SDL/rev/e723c663ba58

On 2016-11-02 17:50:35 +0000, Sam Lantinga wrote:

Whoops, sorry for the mis-attribution. I had pulled it from Ubuntu, which I didn't realize had pulled it upstream from you.

Cheers!

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