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 97856e87ae760e6d
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
     1.1 --- a/Makefile.in	Thu Jun 25 07:17:08 2015 -0700
     1.2 +++ b/Makefile.in	Mon Jun 29 22:24:00 2015 -0700
     1.3 @@ -176,6 +176,8 @@
     1.4  	$(INSTALL) -m 644 $(srcdir)/sdl2.m4 $(DESTDIR)$(datadir)/aclocal/sdl2.m4
     1.5  	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)/pkgconfig
     1.6  	$(INSTALL) -m 644 sdl2.pc $(DESTDIR)$(libdir)/pkgconfig
     1.7 +	$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)/cmake/SDL2
     1.8 +	$(INSTALL) -m 644 sdl2-config.cmake $(DESTDIR)$(libdir)/cmake/SDL2
     1.9  
    1.10  uninstall: uninstall-bin uninstall-hdrs uninstall-lib uninstall-data
    1.11  uninstall-bin:
    1.12 @@ -194,6 +196,7 @@
    1.13  uninstall-data:
    1.14  	rm -f $(DESTDIR)$(datadir)/aclocal/sdl2.m4
    1.15  	rm -f $(DESTDIR)$(libdir)/pkgconfig/sdl2.pc
    1.16 +	rm -f $(DESTDIR)$(libdir)/cmake/SDL2/sdl2-config.cmake
    1.17  
    1.18  clean:
    1.19  	rm -rf $(objects)
     2.1 --- a/configure	Thu Jun 25 07:17:08 2015 -0700
     2.2 +++ b/configure	Mon Jun 29 22:24:00 2015 -0700
     2.3 @@ -23764,7 +23764,7 @@
     2.4  $SDLTEST_DEPENDS
     2.5  __EOF__
     2.6  
     2.7 -ac_config_files="$ac_config_files Makefile:Makefile.in:Makefile.rules sdl2-config SDL2.spec sdl2.pc"
     2.8 +ac_config_files="$ac_config_files Makefile:Makefile.in:Makefile.rules sdl2-config sdl2-config.cmake SDL2.spec sdl2.pc"
     2.9  
    2.10  ac_config_commands="$ac_config_commands sdl2_config"
    2.11  
    2.12 @@ -24883,6 +24883,7 @@
    2.13      "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
    2.14      "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile:Makefile.in:Makefile.rules" ;;
    2.15      "sdl2-config") CONFIG_FILES="$CONFIG_FILES sdl2-config" ;;
    2.16 +    "sdl2-config.cmake") CONFIG_FILES="$CONFIG_FILES sdl2-config.cmake" ;;
    2.17      "SDL2.spec") CONFIG_FILES="$CONFIG_FILES SDL2.spec" ;;
    2.18      "sdl2.pc") CONFIG_FILES="$CONFIG_FILES sdl2.pc" ;;
    2.19      "sdl2_config") CONFIG_COMMANDS="$CONFIG_COMMANDS sdl2_config" ;;
     3.1 --- a/configure.in	Thu Jun 25 07:17:08 2015 -0700
     3.2 +++ b/configure.in	Mon Jun 29 22:24:00 2015 -0700
     3.3 @@ -3533,7 +3533,7 @@
     3.4  __EOF__
     3.5  
     3.6  AC_CONFIG_FILES([
     3.7 -    Makefile:Makefile.in:Makefile.rules sdl2-config SDL2.spec sdl2.pc
     3.8 +    Makefile:Makefile.in:Makefile.rules sdl2-config sdl2-config.cmake SDL2.spec sdl2.pc
     3.9  ])
    3.10  AC_CONFIG_COMMANDS([sdl2_config],[chmod a+x sdl2-config])
    3.11  
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/sdl2-config.cmake.in	Mon Jun 29 22:24:00 2015 -0700
     4.3 @@ -0,0 +1,10 @@
     4.4 +# sdl2 cmake project-config input for ./configure scripts
     4.5 +
     4.6 +set(prefix "@prefix@") 
     4.7 +set(exec_prefix "@exec_prefix@")
     4.8 +set(libdir "@libdir")
     4.9 +set(SDL2_PREFIX "@prefix@")
    4.10 +set(SDL2_EXEC_PREFIX "@prefix@")
    4.11 +set(SDL2_LIBDIR "@libdir@")
    4.12 +set(SDL2_INCLUDE_DIRS "@includedir@/SDL2")
    4.13 +set(SDL2_LIBRARIES "-L${SDL2_LIBDIR} @SDL_RLD_FLAGS@ @SDL_LIBS@")