libsdl-org/sdl2-compat

`sdl2-config --cflags` vs header install path

icculus opened this issue · 2 comments

sdl2-config --cflags reports, among other things, this include path...

-I/usr/local/include/SDL

...but it installs its headers in /usr/local/include/SDL2

One of these two is incorrect.

sezero commented

sdl2-config is wrong. The following fixes it:

diff --git a/sdl2-config.in b/sdl2-config.in
index e564bf3..d21b1b2 100755
--- a/sdl2-config.in
+++ b/sdl2-config.in
@@ -50,7 +50,7 @@ while test $# -gt 0; do
       echo @PROJECT_VERSION@
       ;;
     --cflags)
-      echo -I${includedir}/SDL @SDL_CFLAGS@
+      echo -I${includedir}/SDL2 @SDL_CFLAGS@
       ;;
 @ENABLE_SHARED_TRUE@    --libs)
 @ENABLE_SHARED_TRUE@      echo -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@
diff --git a/sdl2_compat.pc.in b/sdl2_compat.pc.in
index 3518708..2f0f9c0 100644
--- a/sdl2_compat.pc.in
+++ b/sdl2_compat.pc.in
@@ -8,7 +8,7 @@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
 Name: sdl2_compat
 Description: An SDL2 compatibility layer that uses SDL3 behind the scenes.
 Version: @PROJECT_VERSION@
-Provides: sdl = @PROJECT_VERSION@
+Provides: sdl2 = @PROJECT_VERSION@
 Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@
 @ENABLE_STATIC_TRUE@Libs.private: -L${libdir} @SDL_LIBS@ @SDL_STATIC_LIBS@
 Cflags: -I${includedir}/SDL2 @SDL_CFLAGS@

Note the changes to pkg-config file as well: should be a copy+paste error from sdl12-compat.
However: upon running pkg-config, I get an error:

$ PKG_CONFIG_PATH=~/x2/lib/pkgconfig pkg-config --cflags sdl2
Package sdl2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `sdl2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'sdl2' found

Same thing happens with sdl12-compat. Both install the compat pc files, i.e.
sdl12_compat.pc and sdl2_compat.pc, not sdl.pc or sdl2.pc. Is this supposed
to happen? How is it supposed to work?

sezero commented

sdl2-config is wrong. The following fixes it:

diff --git a/sdl2-config.in b/sdl2-config.in
index e564bf3..d21b1b2 100755
--- a/sdl2-config.in
+++ b/sdl2-config.in
@@ -50,7 +50,7 @@ while test $# -gt 0; do
       echo @PROJECT_VERSION@
       ;;
     --cflags)
-      echo -I${includedir}/SDL @SDL_CFLAGS@
+      echo -I${includedir}/SDL2 @SDL_CFLAGS@
       ;;
 @ENABLE_SHARED_TRUE@    --libs)
 @ENABLE_SHARED_TRUE@      echo -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@
diff --git a/sdl2_compat.pc.in b/sdl2_compat.pc.in
index 3518708..2f0f9c0 100644
--- a/sdl2_compat.pc.in
+++ b/sdl2_compat.pc.in
@@ -8,7 +8,7 @@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
 Name: sdl2_compat
 Description: An SDL2 compatibility layer that uses SDL3 behind the scenes.
 Version: @PROJECT_VERSION@
-Provides: sdl = @PROJECT_VERSION@
+Provides: sdl2 = @PROJECT_VERSION@
 Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@
 @ENABLE_STATIC_TRUE@Libs.private: -L${libdir} @SDL_LIBS@ @SDL_STATIC_LIBS@
 Cflags: -I${includedir}/SDL2 @SDL_CFLAGS@

upon running pkg-config, I get an error:

$ PKG_CONFIG_PATH=~/x2/lib/pkgconfig pkg-config --cflags sdl2
Package sdl2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `sdl2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'sdl2' found

Same thing happens with sdl12-compat. Both install the compat pc files, i.e. sdl12_compat.pc and sdl2_compat.pc, not sdl.pc or sdl2.pc. Is this supposed to happen? How is it supposed to work?

Looks like it relies on the Provides field support in pkgconf (which distros seem to prefer these days) not something supported by traditional pkg-config.