mirror of https://github.com/encounter/SDL.git
build: Merge pkg-config Libs.private into Libs for static-only builds
A project being built entirely statically will call pkg-config with --static, which utilises the Libs.private field. Conversely it will not use --static when not being built entirely statically, even if there is only a static build of SDL available. This will most likely cause the build to fail due to underlinking unless we merge the Libs fields. This is what the Meson build system does when it generates pkg-config files. This also also follows the behaviour of sdl2-config. At the same time, the runtime linker flags are not applicable to static-only builds so only add them for shared builds.
This commit is contained in:
parent
bd7b4f39ed
commit
99f87a7158
|
@ -1279,8 +1279,8 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS)
|
||||||
set(HAVE_SDL_TIMERS TRUE)
|
set(HAVE_SDL_TIMERS TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(RPATH)
|
|
||||||
set(SDL_RLD_FLAGS "")
|
set(SDL_RLD_FLAGS "")
|
||||||
|
if(RPATH AND SDL_SHARED)
|
||||||
if(BSDI OR FREEBSD OR LINUX OR NETBSD)
|
if(BSDI OR FREEBSD OR LINUX OR NETBSD)
|
||||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--enable-new-dtags")
|
set(CMAKE_REQUIRED_FLAGS "-Wl,--enable-new-dtags")
|
||||||
check_c_compiler_flag("" HAVE_ENABLE_NEW_DTAGS)
|
check_c_compiler_flag("" HAVE_ENABLE_NEW_DTAGS)
|
||||||
|
@ -1950,9 +1950,12 @@ if(NOT WINDOWS OR CYGWIN)
|
||||||
set(ENABLE_STATIC_FALSE "")
|
set(ENABLE_STATIC_FALSE "")
|
||||||
endif()
|
endif()
|
||||||
if(SDL_SHARED)
|
if(SDL_SHARED)
|
||||||
|
set(PKG_CONFIG_LIBS_PRIV "
|
||||||
|
Libs.private:")
|
||||||
set(ENABLE_SHARED_TRUE "")
|
set(ENABLE_SHARED_TRUE "")
|
||||||
set(ENABLE_SHARED_FALSE "#")
|
set(ENABLE_SHARED_FALSE "#")
|
||||||
else()
|
else()
|
||||||
|
set(PKG_CONFIG_LIBS_PRIV "")
|
||||||
set(ENABLE_SHARED_TRUE "#")
|
set(ENABLE_SHARED_TRUE "#")
|
||||||
set(ENABLE_SHARED_FALSE "")
|
set(ENABLE_SHARED_FALSE "")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -647,6 +647,7 @@ ENABLE_STATIC_FALSE
|
||||||
ENABLE_STATIC_TRUE
|
ENABLE_STATIC_TRUE
|
||||||
ENABLE_SHARED_FALSE
|
ENABLE_SHARED_FALSE
|
||||||
ENABLE_SHARED_TRUE
|
ENABLE_SHARED_TRUE
|
||||||
|
PKG_CONFIG_LIBS_PRIV
|
||||||
SDL_RLD_FLAGS
|
SDL_RLD_FLAGS
|
||||||
SDL_STATIC_LIBS
|
SDL_STATIC_LIBS
|
||||||
SDL_LIBS
|
SDL_LIBS
|
||||||
|
@ -25675,7 +25676,7 @@ SDLTEST_DEPENDS=`echo "$SDLTEST_DEPENDS" | sed "s,\\([^ ]*\\)/\\([^ ]*\\)\\.c,\\
|
||||||
|
|
||||||
# Set runtime shared library paths as needed
|
# Set runtime shared library paths as needed
|
||||||
|
|
||||||
if test "x$enable_rpath" = "xyes"; then
|
if test "x$enable_rpath" = "xyes" -a "x$enable_shared" = "xyes"; then
|
||||||
if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = linux -o $ARCH = netbsd; then
|
if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = linux -o $ARCH = netbsd; then
|
||||||
SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
|
SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
|
||||||
|
|
||||||
|
@ -25723,9 +25724,12 @@ SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
|
||||||
|
|
||||||
|
|
||||||
if test x$enable_shared = xyes; then
|
if test x$enable_shared = xyes; then
|
||||||
|
PKG_CONFIG_LIBS_PRIV="
|
||||||
|
Libs.private:"
|
||||||
ENABLE_SHARED_TRUE=
|
ENABLE_SHARED_TRUE=
|
||||||
ENABLE_SHARED_FALSE="#"
|
ENABLE_SHARED_FALSE="#"
|
||||||
else
|
else
|
||||||
|
PKG_CONFIG_LIBS_PRIV=
|
||||||
ENABLE_SHARED_TRUE="#"
|
ENABLE_SHARED_TRUE="#"
|
||||||
ENABLE_SHARED_FALSE=
|
ENABLE_SHARED_FALSE=
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -4247,7 +4247,7 @@ SDLTEST_DEPENDS=`echo "$SDLTEST_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.
|
||||||
|
|
||||||
# Set runtime shared library paths as needed
|
# Set runtime shared library paths as needed
|
||||||
|
|
||||||
if test "x$enable_rpath" = "xyes"; then
|
if test "x$enable_rpath" = "xyes" -a "x$enable_shared" = "xyes"; then
|
||||||
if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = linux -o $ARCH = netbsd; then
|
if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = linux -o $ARCH = netbsd; then
|
||||||
SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
|
SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
|
||||||
|
|
||||||
|
@ -4279,9 +4279,12 @@ AC_SUBST(SDL_LIBS)
|
||||||
AC_SUBST(SDL_STATIC_LIBS)
|
AC_SUBST(SDL_STATIC_LIBS)
|
||||||
AC_SUBST(SDL_RLD_FLAGS)
|
AC_SUBST(SDL_RLD_FLAGS)
|
||||||
if test x$enable_shared = xyes; then
|
if test x$enable_shared = xyes; then
|
||||||
|
PKG_CONFIG_LIBS_PRIV="
|
||||||
|
Libs.private:"
|
||||||
ENABLE_SHARED_TRUE=
|
ENABLE_SHARED_TRUE=
|
||||||
ENABLE_SHARED_FALSE="#"
|
ENABLE_SHARED_FALSE="#"
|
||||||
else
|
else
|
||||||
|
PKG_CONFIG_LIBS_PRIV=
|
||||||
ENABLE_SHARED_TRUE="#"
|
ENABLE_SHARED_TRUE="#"
|
||||||
ENABLE_SHARED_FALSE=
|
ENABLE_SHARED_FALSE=
|
||||||
fi
|
fi
|
||||||
|
@ -4292,6 +4295,7 @@ else
|
||||||
ENABLE_STATIC_TRUE="#"
|
ENABLE_STATIC_TRUE="#"
|
||||||
ENABLE_STATIC_FALSE=
|
ENABLE_STATIC_FALSE=
|
||||||
fi
|
fi
|
||||||
|
AC_SUBST(PKG_CONFIG_LIBS_PRIV)
|
||||||
AC_SUBST(ENABLE_SHARED_TRUE)
|
AC_SUBST(ENABLE_SHARED_TRUE)
|
||||||
AC_SUBST(ENABLE_SHARED_FALSE)
|
AC_SUBST(ENABLE_SHARED_FALSE)
|
||||||
AC_SUBST(ENABLE_STATIC_TRUE)
|
AC_SUBST(ENABLE_STATIC_TRUE)
|
||||||
|
|
|
@ -15,7 +15,7 @@ if(NOT TARGET SDL2::SDL2)
|
||||||
# This may require "libdir" beeing set (from above)
|
# This may require "libdir" beeing set (from above)
|
||||||
string(REPLACE "-lSDL2 " "" SDL2_EXTRA_LINK_FLAGS "@SDL_RLD_FLAGS@ @SDL_LIBS@ ")
|
string(REPLACE "-lSDL2 " "" SDL2_EXTRA_LINK_FLAGS "@SDL_RLD_FLAGS@ @SDL_LIBS@ ")
|
||||||
string(STRIP "${SDL2_EXTRA_LINK_FLAGS}" SDL2_EXTRA_LINK_FLAGS)
|
string(STRIP "${SDL2_EXTRA_LINK_FLAGS}" SDL2_EXTRA_LINK_FLAGS)
|
||||||
string(REPLACE "-lSDL2 " "" SDL2_EXTRA_LINK_FLAGS_STATIC "@SDL_RLD_FLAGS@ @SDL_STATIC_LIBS@ ")
|
string(REPLACE "-lSDL2 " "" SDL2_EXTRA_LINK_FLAGS_STATIC "@SDL_STATIC_LIBS@ ")
|
||||||
string(STRIP "${SDL2_EXTRA_LINK_FLAGS_STATIC}" SDL2_EXTRA_LINK_FLAGS_STATIC)
|
string(STRIP "${SDL2_EXTRA_LINK_FLAGS_STATIC}" SDL2_EXTRA_LINK_FLAGS_STATIC)
|
||||||
|
|
||||||
add_library(SDL2::SDL2 SHARED IMPORTED)
|
add_library(SDL2::SDL2 SHARED IMPORTED)
|
||||||
|
|
|
@ -49,7 +49,7 @@ while test $# -gt 0; do
|
||||||
@ENABLE_SHARED_TRUE@ ;;
|
@ENABLE_SHARED_TRUE@ ;;
|
||||||
@ENABLE_STATIC_TRUE@@ENABLE_SHARED_TRUE@ --static-libs)
|
@ENABLE_STATIC_TRUE@@ENABLE_SHARED_TRUE@ --static-libs)
|
||||||
@ENABLE_STATIC_TRUE@@ENABLE_SHARED_FALSE@ --libs|--static-libs)
|
@ENABLE_STATIC_TRUE@@ENABLE_SHARED_FALSE@ --libs|--static-libs)
|
||||||
@ENABLE_STATIC_TRUE@ echo -L@libdir@ @SDL_RLD_FLAGS@ @SDL_STATIC_LIBS@
|
@ENABLE_STATIC_TRUE@ echo -L@libdir@ @SDL_STATIC_LIBS@
|
||||||
@ENABLE_STATIC_TRUE@ ;;
|
@ENABLE_STATIC_TRUE@ ;;
|
||||||
*)
|
*)
|
||||||
echo "${usage}" 1>&2
|
echo "${usage}" 1>&2
|
||||||
|
|
|
@ -10,6 +10,5 @@ Description: Simple DirectMedia Layer is a cross-platform multimedia library des
|
||||||
Version: @SDL_VERSION@
|
Version: @SDL_VERSION@
|
||||||
Requires:
|
Requires:
|
||||||
Conflicts:
|
Conflicts:
|
||||||
Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@
|
Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@ @PKG_CONFIG_LIBS_PRIV@ @SDL_STATIC_LIBS@
|
||||||
Libs.private: @SDL_STATIC_LIBS@
|
|
||||||
Cflags: -I${includedir}/SDL2 @SDL_CFLAGS@
|
Cflags: -I${includedir}/SDL2 @SDL_CFLAGS@
|
||||||
|
|
Loading…
Reference in New Issue