Fixed bug 2464 - Configure a sdl2-config.cmake.in together with sdl2.pc.in
authorSam Lantinga <slouken@libsdl.org>
Mon, 29 Jun 2015 22:24:00 -0700
changeset 9785 6e87ae760e6d
parent 9784 7d5a98aac368
child 9786 d857f324bede
Fixed bug 2464 - Configure a sdl2-config.cmake.in together with sdl2.pc.in Leonardo Despite having a CMakeLists.txt file, SDL2 seems to be mainly built using the autotools system by package-managers. It is nice to have it but it is only useful if you are building SDL2 by yourself. People that want to use CMake to find their already-installed SDL2 are using a FindSDL2.cmake module based on the old FindSDL.cmake. This is not deprecated but it is discouraged by the CMake devs (see http://www.cmake.org/Bug/view.php?id=14826), as these modules needs maintainers to be included in the official CMake installation. To fix that, SDL and its accompanying libraries could configure a simple sdl2-config.cmake file, much like it does with sdl2.pc.in. We don't need to configure a full sdl2-config.cmake as in this post, http://forums.libsdl.org/viewtopic.php?t=10068&sid=ccf8abbf0d73fb03ae9cded991e60959 (because it depends on it being built with CMake). Using something as simple as http://www.cmake.org/Wiki/CMake/Tutorials/Packaging#Package_Configuration_Files is deemed enough. Here is another: http://quickgit.kde.org/?p=prison.git&a=blob&f=lib%2Fprison%2FPrisonConfig.cmake.in
Makefile.in
configure
configure.in
sdl2-config.cmake.in
--- a/Makefile.in	Thu Jun 25 07:17:08 2015 -0700
+++ b/Makefile.in	Mon Jun 29 22:24:00 2015 -0700
@@ -176,6 +176,8 @@
 	$(INSTALL) -m 644 $(srcdir)/sdl2.m4 $(DESTDIR)$(datadir)/aclocal/sdl2.m4
 	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)/pkgconfig
 	$(INSTALL) -m 644 sdl2.pc $(DESTDIR)$(libdir)/pkgconfig
+	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)/cmake/SDL2
+	$(INSTALL) -m 644 sdl2-config.cmake $(DESTDIR)$(libdir)/cmake/SDL2
 
 uninstall: uninstall-bin uninstall-hdrs uninstall-lib uninstall-data
 uninstall-bin:
@@ -194,6 +196,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
 
 clean:
 	rm -rf $(objects)
--- a/configure	Thu Jun 25 07:17:08 2015 -0700
+++ b/configure	Mon Jun 29 22:24:00 2015 -0700
@@ -23764,7 +23764,7 @@
 $SDLTEST_DEPENDS
 __EOF__
 
-ac_config_files="$ac_config_files Makefile:Makefile.in:Makefile.rules sdl2-config SDL2.spec sdl2.pc"
+ac_config_files="$ac_config_files Makefile:Makefile.in:Makefile.rules sdl2-config sdl2-config.cmake SDL2.spec sdl2.pc"
 
 ac_config_commands="$ac_config_commands sdl2_config"
 
@@ -24883,6 +24883,7 @@
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
     "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.spec") CONFIG_FILES="$CONFIG_FILES SDL2.spec" ;;
     "sdl2.pc") CONFIG_FILES="$CONFIG_FILES sdl2.pc" ;;
     "sdl2_config") CONFIG_COMMANDS="$CONFIG_COMMANDS sdl2_config" ;;
--- a/configure.in	Thu Jun 25 07:17:08 2015 -0700
+++ b/configure.in	Mon Jun 29 22:24:00 2015 -0700
@@ -3533,7 +3533,7 @@
 __EOF__
 
 AC_CONFIG_FILES([
-    Makefile:Makefile.in:Makefile.rules sdl2-config SDL2.spec sdl2.pc
+    Makefile:Makefile.in:Makefile.rules sdl2-config sdl2-config.cmake SDL2.spec sdl2.pc
 ])
 AC_CONFIG_COMMANDS([sdl2_config],[chmod a+x sdl2-config])
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sdl2-config.cmake.in	Mon Jun 29 22:24:00 2015 -0700
@@ -0,0 +1,10 @@
+# sdl2 cmake project-config input for ./configure scripts
+
+set(prefix "@prefix@") 
+set(exec_prefix "@exec_prefix@")
+set(libdir "@libdir")
+set(SDL2_PREFIX "@prefix@")
+set(SDL2_EXEC_PREFIX "@prefix@")
+set(SDL2_LIBDIR "@libdir@")
+set(SDL2_INCLUDE_DIRS "@includedir@/SDL2")
+set(SDL2_LIBRARIES "-L${SDL2_LIBDIR} @SDL_RLD_FLAGS@ @SDL_LIBS@")