cmake: more proper sdl2-config.cmake work (thanks, Alexander!)

Fixes Bugzilla #4970.
This commit is contained in:
Ryan C. Gordon 2020-02-21 15:52:35 -05:00
parent be4d488e04
commit dd1d8ab62c
5 changed files with 35 additions and 3 deletions

View file

@ -46,7 +46,7 @@ WAYLAND_SCANNER = @WAYLAND_SCANNER@
INSTALL_SDL2_CONFIG = @INSTALL_SDL2_CONFIG@
SRC_DIST = *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake cmake_uninstall.cmake.in configure configure.ac debian docs include Makefile.* sdl2-config.cmake.in sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in SDL2Config.cmake src test VisualC.html VisualC VisualC-WinRT Xcode Xcode-iOS wayland-protocols
SRC_DIST = *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake cmake_uninstall.cmake.in configure configure.ac debian docs include Makefile.* sdl2-config.cmake.in sdl2-config-version.cmake.in sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in SDL2Config.cmake src test VisualC.html VisualC VisualC-WinRT Xcode Xcode-iOS wayland-protocols
GEN_DIST = SDL2.spec
ifneq ($V,1)
@ -188,6 +188,7 @@ install-data:
ifeq ($(INSTALL_SDL2_CONFIG),TRUE)
$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)/cmake/SDL2
$(INSTALL) -m 644 sdl2-config.cmake $(DESTDIR)$(libdir)/cmake/SDL2
$(INSTALL) -m 644 sdl2-config-version.cmake $(DESTDIR)$(libdir)/cmake/SDL2
endif
uninstall: uninstall-bin uninstall-hdrs uninstall-lib uninstall-data
@ -208,6 +209,7 @@ uninstall-data:
rm -f $(DESTDIR)$(datadir)/aclocal/sdl2.m4
rm -f $(DESTDIR)$(libdir)/pkgconfig/sdl2.pc
rm -f $(DESTDIR)$(libdir)/cmake/SDL2/sdl2-config.cmake
rm -f $(DESTDIR)$(libdir)/cmake/SDL2/sdl2-config-version.cmake
clean:
rm -rf $(objects)

3
configure vendored
View file

@ -25627,7 +25627,7 @@ $SDLTEST_DEPENDS
$WAYLAND_PROTOCOLS_DEPENDS
__EOF__
ac_config_files="$ac_config_files Makefile:Makefile.in:Makefile.rules sdl2-config sdl2-config.cmake SDL2.spec sdl2.pc"
ac_config_files="$ac_config_files Makefile:Makefile.in:Makefile.rules sdl2-config sdl2-config.cmake sdl2-config-version.cmake SDL2.spec sdl2.pc"
ac_config_commands="$ac_config_commands sdl2_config"
@ -26779,6 +26779,7 @@ do
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile:Makefile.in:Makefile.rules" ;;
"sdl2-config") CONFIG_FILES="$CONFIG_FILES sdl2-config" ;;
"sdl2-config.cmake") CONFIG_FILES="$CONFIG_FILES sdl2-config.cmake" ;;
"sdl2-config-version.cmake") CONFIG_FILES="$CONFIG_FILES sdl2-config-version.cmake" ;;
"SDL2.spec") CONFIG_FILES="$CONFIG_FILES SDL2.spec" ;;
"sdl2.pc") CONFIG_FILES="$CONFIG_FILES sdl2.pc" ;;
"sdl2_config") CONFIG_COMMANDS="$CONFIG_COMMANDS sdl2_config" ;;

View file

@ -4293,7 +4293,7 @@ $WAYLAND_PROTOCOLS_DEPENDS
__EOF__
AC_CONFIG_FILES([
Makefile:Makefile.in:Makefile.rules sdl2-config sdl2-config.cmake SDL2.spec sdl2.pc
Makefile:Makefile.in:Makefile.rules sdl2-config sdl2-config.cmake sdl2-config-version.cmake SDL2.spec sdl2.pc
])
AC_CONFIG_COMMANDS([sdl2_config],[chmod a+x sdl2-config])

View file

@ -5,4 +5,5 @@ usr/lib/*/*.la
usr/lib/*/*.so
usr/lib/*/pkgconfig/sdl2.pc
usr/lib/*/cmake/SDL2/sdl2-config.cmake
usr/lib/*/cmake/SDL2/sdl2-config-version.cmake
usr/share/aclocal/sdl2.m4

View file

@ -9,3 +9,31 @@ set(SDL2_LIBDIR "@libdir@")
set(SDL2_INCLUDE_DIRS "@includedir@/SDL2")
set(SDL2_LIBRARIES "-L${SDL2_LIBDIR} @SDL_RLD_FLAGS@ @SDL_LIBS@")
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 "@SDL_RLD_FLAGS@ @SDL_LIBS@ ")
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(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 "@includedir@/SDL2"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "@libdir@/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 "@includedir@/SDL2"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "@libdir@/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 "@libdir@/libSDL2main.a")
endif()