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

CMAKE: Generated target import file contains incorrect include path #2864

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

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

Comments on the original bug report:

On 2018-04-08 10:10:53 +0000, wrote:

Created attachment 3216
Test program

When building SDL2 using the CMake build system, the generated SDL2Targets.cmake file sets the include path to ${_IMPORT_PREFIX}/include instead of ${_IMPORT_PREFIX}/include/SDL2.

This causes applications using the following in their CMakeLists.txt to detect and include SDL2 to fail building:

Find_Package(SDL2 REQUIRED)
target_link_libraries(test SDL2::SDL2)

Steps to reproduce:

  1. Build and install SDL2 using CMake
  2. Try to build the attached reproducer (cmake . && make)

This fails with the error test.c:1:10: SDL.h : No such file or directory

Edit the installed SDL2Targets.cmake, replace:

set_target_properties(SDL2::SDL2 PROPERTIES
        INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
)

with:
set_target_properties(SDL2::SDL2 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/SDL2"
)

the reproducer now builds as expected.

On 2018-04-10 15:05:44 +0000, Sam Lantinga wrote:

The correct include statement is #include "SDL2/SDL.h"

On 2018-04-10 16:37:31 +0000, wrote:

But then, it's not consistent with the include path provided to CMake applications using SDL2 built using autotools,
see https://hg.libsdl.org/SDL/file/bfb936894a9d/sdl2-config.cmake.in

Also applications have been doing #include "SDL.h" for years, it seems a bit harsh breaking their build when distributions decide to switch SDL2 from autotools to CMake (which is what happened with ArchLinux recently, and the reason I am opening this bug).

On 2018-04-10 21:52:39 +0000, Sam Lantinga wrote:

Whoops, you're right, my mistake.

On 2018-04-10 21:54:50 +0000, Sam Lantinga wrote:

I don't use CMake myself, and I don't see where this is configured in the SDL source files. Can you attach a patch you've tested there?

Thanks!

On 2018-04-11 04:22:24 +0000, wrote:

Created attachment 3219
Proposed fix

I've attached a patch that fixes the issue.

On 2018-04-12 00:18:58 +0000, Sam Lantinga wrote:

Added, thanks!
https://hg.libsdl.org/SDL/rev/4d843a32d74e

On 2020-02-16 02:57:14 +0000, Mohamed wrote:

Created attachment 4218
Allow both types of #include

It would be useful to be able to do either #include "SDL2/SDL.h" or #include "SDL.h". This patch allows that and adds compatibility with other build systems. It also allows differentiating between SDL1 and SDL2.

On 2020-02-16 08:08:54 +0000, Sam Lantinga wrote:

Nice addition, thanks!
https://hg.libsdl.org/SDL/rev/fab2cd7dee5b

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