SDL_image: Learn autotools to generate CMake configuration files

From f257d179fa708136317a6351aa7293e3c90b95d8 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sat, 4 Jun 2022 02:43:44 +0200
Subject: [PATCH] Learn autotools to generate CMake configuration files

---
 Makefile.am                        |  10 ++
 Makefile.in                        |  78 +++++++++++----
 configure                          | 156 ++++++++++++++++++++++++++---
 configure.ac                       |  78 +++++++++++++++
 sdl2_image-config-version.cmake.in |  13 +++
 sdl2_image-config.cmake.in         |  97 ++++++++++++++++++
 test/Makefile.in                   |  23 +++++
 7 files changed, 422 insertions(+), 33 deletions(-)
 create mode 100644 sdl2_image-config-version.cmake.in
 create mode 100644 sdl2_image-config.cmake.in

diff --git a/Makefile.am b/Makefile.am
index bb9fe9cb..1167af89 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -97,3 +97,13 @@ rpm: $(PACKAGE)-$(VERSION).tar.gz
 
 dist-hook:
 	ls $(distdir)/external | fgrep -v download.sh | while read dir; do rm -rf "$(distdir)/external/$$dir"; done
+
+install-data-local:
+	$(MKDIR_P) $(DESTDIR)$(libdir)/cmake/SDL2_image
+	$(INSTALL) -m 644 sdl2_image-config.cmake $(DESTDIR)$(libdir)/cmake/SDL2_image
+	$(INSTALL) -m 644 sdl2_image-config-version.cmake $(DESTDIR)$(libdir)/cmake/SDL2_image
+
+uninstall-hook:
+	rm $(DESTDIR)$(libdir)/cmake/SDL2_image/sdl2_image-config.cmake
+	rm $(DESTDIR)$(libdir)/cmake/SDL2_image/sdl2_image-config-version.cmake
+	rm -r $(DESTDIR)$(libdir)/cmake/SDL2_image
diff --git a/Makefile.in b/Makefile.in
index 5eb64da8..5bd2efaa 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -112,7 +112,8 @@ DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
 mkinstalldirs = $(install_sh) -d
-CONFIG_CLEAN_FILES = SDL2_image.spec SDL2_image.pc
+CONFIG_CLEAN_FILES = sdl2_image-config.cmake \
+	sdl2_image-config-version.cmake SDL2_image.spec SDL2_image.pc
 CONFIG_CLEAN_VPATH_FILES =
 PROGRAMS = $(noinst_PROGRAMS)
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -281,8 +282,10 @@ am__define_uniq_tagged_files = \
   done | $(am__uniquify_input)`
 DIST_SUBDIRS = . test
 am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/SDL2_image.pc.in \
-	$(srcdir)/SDL2_image.spec.in compile config.guess config.sub \
-	depcomp install-sh ltmain.sh missing
+	$(srcdir)/SDL2_image.spec.in \
+	$(srcdir)/sdl2_image-config-version.cmake.in \
+	$(srcdir)/sdl2_image-config.cmake.in compile config.guess \
+	config.sub depcomp install-sh ltmain.sh missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -382,6 +385,23 @@ LIBWEBP_CFLAGS = @LIBWEBP_CFLAGS@
 LIBWEBP_LIBS = @LIBWEBP_LIBS@
 LIPO = @LIPO@
 LN_S = @LN_S@
+LOAD_AVIF = @LOAD_AVIF@
+LOAD_BMP = @LOAD_BMP@
+LOAD_GIF = @LOAD_GIF@
+LOAD_JPG = @LOAD_JPG@
+LOAD_JXL = @LOAD_JXL@
+LOAD_LBM = @LOAD_LBM@
+LOAD_PCX = @LOAD_PCX@
+LOAD_PNG = @LOAD_PNG@
+LOAD_PNM = @LOAD_PNM@
+LOAD_QOI = @LOAD_QOI@
+LOAD_SVG = @LOAD_SVG@
+LOAD_TGA = @LOAD_TGA@
+LOAD_TIF = @LOAD_TIF@
+LOAD_WEBP = @LOAD_WEBP@
+LOAD_XCF = @LOAD_XCF@
+LOAD_XPM = @LOAD_XPM@
+LOAD_XV = @LOAD_XV@
 LTLIBOBJS = @LTLIBOBJS@
 LT_AGE = @LT_AGE@
 LT_CURRENT = @LT_CURRENT@
@@ -417,6 +437,8 @@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
 RANLIB = @RANLIB@
 RC = @RC@
+SDL2IMAGE_JPG_SAVE = @SDL2IMAGE_JPG_SAVE@
+SDL2IMAGE_PNG_SAVE = @SDL2IMAGE_PNG_SAVE@
 SDL2_CONFIG = @SDL2_CONFIG@
 SDL_CFLAGS = @SDL_CFLAGS@
 SDL_LIBS = @SDL_LIBS@
@@ -425,6 +447,9 @@ SED = @SED@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
+USE_IMAGEIO = @USE_IMAGEIO@
+USE_STBIMAGE = @USE_STBIMAGE@
+USE_WIC = @USE_WIC@
 VERSION = @VERSION@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
@@ -445,6 +470,7 @@ build_cpu = @build_cpu@
 build_os = @build_os@
 build_vendor = @build_vendor@
 builddir = @builddir@
+cmake_prefix_relpath = @cmake_prefix_relpath@
 datadir = @datadir@
 datarootdir = @datarootdir@
 docdir = @docdir@
@@ -588,6 +614,10 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
 $(am__aclocal_m4_deps):
+sdl2_image-config.cmake: $(top_builddir)/config.status $(srcdir)/sdl2_image-config.cmake.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
+sdl2_image-config-version.cmake: $(top_builddir)/config.status $(srcdir)/sdl2_image-config-version.cmake.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
 SDL2_image.spec: $(top_builddir)/config.status $(srcdir)/SDL2_image.spec.in
 	cd $(top_builddir) && $(SHELL) ./config.status $@
 SDL2_image.pc: $(top_builddir)/config.status $(srcdir)/SDL2_image.pc.in
@@ -1166,8 +1196,8 @@ info: info-recursive
 
 info-am:
 
-install-data-am: install-libSDL2_imageincludeHEADERS \
-	install-pkgconfigDATA
+install-data-am: install-data-local \
+	install-libSDL2_imageincludeHEADERS install-pkgconfigDATA
 
 install-dvi: install-dvi-recursive
 
@@ -1239,8 +1269,9 @@ ps-am:
 
 uninstall-am: uninstall-libLTLIBRARIES \
 	uninstall-libSDL2_imageincludeHEADERS uninstall-pkgconfigDATA
-
-.MAKE: $(am__recursive_targets) install-am install-strip
+	@$(NORMAL_INSTALL)
+	$(MAKE) $(AM_MAKEFLAGS) uninstall-hook
+.MAKE: $(am__recursive_targets) install-am install-strip uninstall-am
 
 .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
 	am--depfiles am--refresh check check-am clean clean-cscope \
@@ -1251,17 +1282,18 @@ uninstall-am: uninstall-libLTLIBRARIES \
 	distclean-compile distclean-generic distclean-libtool \
 	distclean-tags distcleancheck distdir distuninstallcheck dvi \
 	dvi-am html html-am info info-am install install-am \
-	install-data install-data-am install-dvi install-dvi-am \
-	install-exec install-exec-am install-html install-html-am \
-	install-info install-info-am install-libLTLIBRARIES \
-	install-libSDL2_imageincludeHEADERS install-man install-pdf \
-	install-pdf-am install-pkgconfigDATA install-ps install-ps-am \
-	install-strip installcheck installcheck-am installdirs \
-	installdirs-am maintainer-clean maintainer-clean-generic \
-	mostlyclean mostlyclean-compile mostlyclean-generic \
-	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
-	uninstall-am uninstall-libLTLIBRARIES \
-	uninstall-libSDL2_imageincludeHEADERS uninstall-pkgconfigDATA
+	install-data install-data-am install-data-local install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am \
+	install-libLTLIBRARIES install-libSDL2_imageincludeHEADERS \
+	install-man install-pdf install-pdf-am install-pkgconfigDATA \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags tags-am uninstall uninstall-am uninstall-hook \
+	uninstall-libLTLIBRARIES uninstall-libSDL2_imageincludeHEADERS \
+	uninstall-pkgconfigDATA
 
 .PRECIOUS: Makefile
 
@@ -1279,6 +1311,16 @@ rpm: $(PACKAGE)-$(VERSION).tar.gz
 dist-hook:
 	ls $(distdir)/external | fgrep -v download.sh | while read dir; do rm -rf "$(distdir)/external/$$dir"; done
 
+install-data-local:
+	$(MKDIR_P) $(DESTDIR)$(libdir)/cmake/SDL2_image
+	$(INSTALL) -m 644 sdl2_image-config.cmake $(DESTDIR)$(libdir)/cmake/SDL2_image
+	$(INSTALL) -m 644 sdl2_image-config-version.cmake $(DESTDIR)$(libdir)/cmake/SDL2_image
+
+uninstall-hook:
+	rm $(DESTDIR)$(libdir)/cmake/SDL2_image/sdl2_image-config.cmake
+	rm $(DESTDIR)$(libdir)/cmake/SDL2_image/sdl2_image-config-version.cmake
+	rm -r $(DESTDIR)$(libdir)/cmake/SDL2_image
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/configure b/configure
index d4ce48ff..5fde8259 100755
--- a/configure
+++ b/configure
@@ -775,6 +775,7 @@ ac_subst_vars='am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
+cmake_prefix_relpath
 INSTALL_TESTS_FALSE
 INSTALL_TESTS_TRUE
 BUILD_TESTS_FALSE
@@ -782,24 +783,46 @@ BUILD_TESTS_TRUE
 PC_REQUIRES
 PC_LIBS
 IMG_LIBS
+SDL2IMAGE_JPG_SAVE
+SDL2IMAGE_PNG_SAVE
+LOAD_QOI
+LOAD_XV
+LOAD_XPM
+LOAD_XCF
+LOAD_TGA
+LOAD_SVG
+LOAD_PNM
+LOAD_PCX
+LOAD_LBM
+LOAD_GIF
+LOAD_BMP
+LOAD_WEBP
 LIBWEBP_LIBS
 LIBWEBP_CFLAGS
+LOAD_TIF
 LIBTIFF_LIBS
 LIBTIFF_CFLAGS
+LOAD_PNG
 LIBPNG_LIBS
 LIBPNG_CFLAGS
+LOAD_JXL
 LIBJXL_LIBS
 LIBJXL_CFLAGS
+LOAD_JPG
 LIBJPEG_LIBS
 LIBJPEG_CFLAGS
+LOAD_AVIF
 LIBAVIF_LIBS
 LIBAVIF_CFLAGS
+USE_WIC
+USE_STBIMAGE
 SDL2_CONFIG
 SDL_LIBS
 SDL_CFLAGS
 SDL_VERSION
 USE_VERSION_RC_FALSE
 USE_VERSION_RC_TRUE
+USE_IMAGEIO
 USE_IMAGEIO_FALSE
 USE_IMAGEIO_TRUE
 PKG_CONFIG_LIBDIR
@@ -4124,13 +4147,13 @@ if ${lt_cv_nm_interface+:} false; then :
 else
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:4127: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:4150: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:4130: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:4153: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:4133: output\"" >&5)
+  (eval echo "\"\$as_me:4156: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -5344,7 +5367,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 5347 "configure"' > conftest.$ac_ext
+  echo '#line 5370 "configure"' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -7169,11 +7192,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7172: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7195: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7176: \$? = $ac_status" >&5
+   echo "$as_me:7199: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -7518,11 +7541,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7521: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7544: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7525: \$? = $ac_status" >&5
+   echo "$as_me:7548: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -7623,11 +7646,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7626: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7649: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:7630: \$? = $ac_status" >&5
+   echo "$as_me:7653: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -7678,11 +7701,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7681: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7704: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:7685: \$? = $ac_status" >&5
+   echo "$as_me:7708: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -10113,7 +10136,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10116 "configure"
+#line 10139 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10209,7 +10232,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10212 "configure"
+#line 10235 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12690,6 +12713,13 @@ else
   USE_IMAGEIO_FALSE=
 fi
 
+if test x$enable_imageio = xyes; then
+    USE_IMAGEIO=1
+
+else
+    USE_IMAGEIO=0
+
+fi
  if test x$use_version_rc = xtrue; then
   USE_VERSION_RC_TRUE=
   USE_VERSION_RC_FALSE='#'
@@ -13377,7 +13407,17 @@ LIBS="$LIBS $SDL_LIBS"
 if test x$enable_stb_image = xyes; then
     $as_echo "#define USE_STBIMAGE 1" >>confdefs.h
 
+    USE_STBIMAGE=1
+
+else
+    USE_STBIMAGE=0
+
 fi
+
+USE_WIC=0
+
+
+load_avif=0
 if test x$enable_avif = xyes; then
 
 pkg_failed=no
@@ -13577,6 +13617,7 @@ fi
                 fi
                 ;;
         esac
+        load_avif=1
     elif test x$enable_avif = xyes; then
         { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find AVIF library (https://github.com/AOMediaCodec/libavif)" >&5
 $as_echo "$as_me: WARNING: *** Unable to find AVIF library (https://github.com/AOMediaCodec/libavif)" >&2;}
@@ -13584,14 +13625,19 @@ $as_echo "$as_me: WARNING: *** Unable to find AVIF library (https://github.com/A
 $as_echo "$as_me: WARNING: AVIF image loading disabled" >&2;}
     fi
 fi
+LOAD_AVIF=$load_avif
+
 
+load_jpg=0
 if test x$enable_jpg = xyes; then
     if test x$enable_stb_image = xyes; then
         $as_echo "#define LOAD_JPG 1" >>confdefs.h
 
+        load_jpg=1
     elif test x$enable_imageio = xyes; then
         $as_echo "#define LOAD_JPG 1" >>confdefs.h
 
+        load_jpg=1
         $as_echo "#define JPG_USES_IMAGEIO 1" >>confdefs.h
 
     else
@@ -13777,6 +13823,7 @@ fi
             if test x$enable_jpg = xyes; then
                 $as_echo "#define LOAD_JPG 1" >>confdefs.h
 
+                load_jpg=1
             fi
 
             case "$host" in
@@ -13801,7 +13848,10 @@ $as_echo "$as_me: WARNING: JPG image loading disabled" >&2;}
         fi
     fi
 fi
+LOAD_JPG=$load_jpg
 
+
+load_jxl=0
 if test x$enable_jxl = xyes; then
 
 pkg_failed=no
@@ -13985,6 +14035,7 @@ fi
         if test x$enable_jxl = xyes; then
             $as_echo "#define LOAD_JXL 1" >>confdefs.h
 
+            load_jxl=1
         fi
 
         case "$host" in
@@ -14008,16 +14059,21 @@ $as_echo "$as_me: WARNING: *** Unable to find JXL library (https://jpegxl.info/)
 $as_echo "$as_me: WARNING: JXL image loading disabled" >&2;}
     fi
 fi
+LOAD_JXL=$load_jxl
+
 
+load_png=0
 if test x$enable_png = xyes; then
     if test x$enable_stb_image = xyes; then
         $as_echo "#define LOAD_PNG 1" >>confdefs.h
 
+        load_png=1
     elif test x$enable_imageio = xyes; then
         $as_echo "#define LOAD_PNG 1" >>confdefs.h
 
         $as_echo "#define PNG_USES_IMAGEIO 1" >>confdefs.h
 
+        load_png=1
     else
 
 pkg_failed=no
@@ -14200,6 +14256,7 @@ fi
         if test x$have_png_hdr = xyes -a x$have_png_lib = xyes; then
             $as_echo "#define LOAD_PNG 1" >>confdefs.h
 
+            load_png=1
 
             case "$host" in
                 *-*-darwin*)
@@ -14223,7 +14280,10 @@ $as_echo "$as_me: WARNING: PNG image loading disabled" >&2;}
         fi
     fi
 fi
+LOAD_PNG=$load_png
 
+
+load_tif=0
 if test x$enable_tif = xyes -a x$enable_imageio != xyes; then
 
 pkg_failed=no
@@ -14406,6 +14466,7 @@ fi
     if test x$have_tif_hdr = xyes -a x$have_tif_lib = xyes; then
         $as_echo "#define LOAD_TIF 1" >>confdefs.h
 
+        load_tif=1
 
         case "$host" in
             *-*-darwin*)
@@ -14428,7 +14489,10 @@ $as_echo "$as_me: WARNING: *** Unable to find Tiff library (http://www.simplesys
 $as_echo "$as_me: WARNING: TIF image loading disabled" >&2;}
     fi
 fi
+LOAD_TIF=$load_tif
+
 
+load_webp=0
 if test x$enable_webpdec = xyes; then
   webplib=webpdecoder
 else
@@ -14620,6 +14684,7 @@ fi
     if test x$have_webp_hdr = xyes -a x$have_webp_lib = xyes; then
         $as_echo "#define LOAD_WEBP 1" >>confdefs.h
 
+        load_webp=1
 
         case "$host" in
             *-*-darwin*)
@@ -14642,61 +14707,107 @@ $as_echo "$as_me: WARNING: *** Unable to find WEBP library (https://developers.g
 $as_echo "$as_me: WARNING: WEBP image loading disabled" >&2;}
     fi
 fi
+LOAD_WEBP=$load_webp
 
+
+load_bmp=0
 if test x$enable_bmp = xyes; then
     $as_echo "#define LOAD_BMP 1" >>confdefs.h
 
+    load_bmp=1
 fi
+LOAD_BMP=$load_bmp
+
 
+load_gif=0
 if test x$enable_gif = xyes; then
     $as_echo "#define LOAD_GIF 1" >>confdefs.h
 
+    load_gif=1
 fi
+LOAD_GIF=$load_gif
 
+
+load_lbm=0
 if test x$enable_lbm = xyes; then
     $as_echo "#define LOAD_LBM 1" >>confdefs.h
 
+    load_lbm=1
 fi
+LOAD_LBM=$load_lbm
+
 
+load_pcx=0
 if test x$enable_pcx = xyes; then
     $as_echo "#define LOAD_PCX 1" >>confdefs.h
 
+    load_pcx=1
 fi
+LOAD_PCX=$load_pcx
 
+
+load_pnm = 0
 if test x$enable_pnm = xyes; then
     $as_echo "#define LOAD_PNM 1" >>confdefs.h
 
+    load_pnm=1
 fi
+LOAD_PNM=$load_pnm
+
 
+load_svg=0
 if test x$enable_svg = xyes; then
     $as_echo "#define LOAD_SVG 1" >>confdefs.h
 
+    load_svg=1
 fi
+LOAD_SVG=$load_svg
 
+
+load_tga=0
 if test x$enable_tga = xyes; then
     $as_echo "#define LOAD_TGA 1" >>confdefs.h
 
+    load_tga=1
 fi
+LOAD_TGA=$load_tga
+
 
+load_xcf=0
 if test x$enable_xcf = xyes; then
     $as_echo "#define LOAD_XCF 1" >>confdefs.h
 
+    load_xcf=1
 fi
+LOAD_XCF=$load_xcf
 
+
+load_xpm=0
 if test x$enable_xpm = xyes; then
     $as_echo "#define LOAD_XPM 1" >>confdefs.h
 
+    load_xpm=1
 fi
+LOAD_XPM=$load_xpm
+
 
+load_xv=0
 if test x$enable_xv = xyes; then
     $as_echo "#define LOAD_XV 1" >>confdefs.h
 
+    load_xv=1
 fi
+LOAD_XV=$load_xv
 
+
+load_qoi=0
 if test x$enable_qoi = xyes; then
     $as_echo "#define LOAD_QOI 1" >>confdefs.h
 
+    load_qoi=1
 fi
+LOAD_QOI=$load_qoi
+
 
 if test x$enable_webp = xyes -a x$have_webp_hdr = xyes -a x$have_webp_lib = xyes; then
     CFLAGS="$LIBWEBP_CFLAGS $CFLAGS"
@@ -14808,16 +14919,24 @@ fi
 if test x$enable_save_png = xyes; then
     $as_echo "#define SDL_IMAGE_SAVE_PNG 1" >>confdefs.h
 
+    SDL2IMAGE_PNG_SAVE=1
+
 else
     $as_echo "#define SDL_IMAGE_SAVE_PNG 0" >>confdefs.h
 
+    SDL2IMAGE_PNG_SAVE=0
+
 fi
 if test x$enable_save_jpg = xyes; then
     $as_echo "#define SDL_IMAGE_SAVE_JPG 1" >>confdefs.h
 
+    SDL2IMAGE_JPG_SAVE=1
+
 else
     $as_echo "#define SDL_IMAGE_SAVE_JPG 0" >>confdefs.h
 
+    SDL2IMAGE_JPG_SAVE=0
+
 fi
 
 
@@ -14841,6 +14960,11 @@ else
 fi
 
 
+eval pkg_prefix=$prefix
+eval pkg_cmakedir=$libdir/cmake/SDL2_image
+cmake_prefix_relpath="$(echo -n "$pkg_cmakedir" | sed -E "s#^$pkg_prefix##" | sed -E "s#[A-Za-z0-9_ .-]+#..#g")"
+
+
 CheckNoUndef
 
 CheckWarnAll
@@ -14850,7 +14974,7 @@ CheckVisibilityHidden
 OBJCFLAGS=$CFLAGS
 
 # Finally create all the generated files
-ac_config_files="$ac_config_files Makefile SDL2_image.spec SDL2_image.pc test/Makefile"
+ac_config_files="$ac_config_files Makefile sdl2_image-config.cmake sdl2_image-config-version.cmake SDL2_image.spec SDL2_image.pc test/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -15872,6 +15996,8 @@ do
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
     "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+    "sdl2_image-config.cmake") CONFIG_FILES="$CONFIG_FILES sdl2_image-config.cmake" ;;
+    "sdl2_image-config-version.cmake") CONFIG_FILES="$CONFIG_FILES sdl2_image-config-version.cmake" ;;
     "SDL2_image.spec") CONFIG_FILES="$CONFIG_FILES SDL2_image.spec" ;;
     "SDL2_image.pc") CONFIG_FILES="$CONFIG_FILES SDL2_image.pc" ;;
     "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index f06d7bec..1e6af992 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,6 +111,11 @@ case "$host" in
         ;;
 esac
 AM_CONDITIONAL(USE_IMAGEIO, test x$enable_imageio = xyes)
+if test x$enable_imageio = xyes; then
+    AC_SUBST([USE_IMAGEIO], 1)
+else
+    AC_SUBST([USE_IMAGEIO], 0)
+fi
 AM_CONDITIONAL(USE_VERSION_RC, test x$use_version_rc = xtrue)
 
 dnl set this to use on systems that use lib64 instead of lib
@@ -287,7 +292,14 @@ LIBS="$LIBS $SDL_LIBS"
 
 if test x$enable_stb_image = xyes; then
     AC_DEFINE([USE_STBIMAGE])
+    AC_SUBST([USE_STBIMAGE], 1)
+else
+    AC_SUBST([USE_STBIMAGE], 0)
 fi
+
+AC_SUBST([USE_WIC], 0)
+
+load_avif=0
 if test x$enable_avif = xyes; then
     PKG_CHECK_MODULES([LIBAVIF], [libavif], [dnl
         have_avif_hdr=yes
@@ -322,17 +334,22 @@ if test x$enable_avif = xyes; then
                 fi
                 ;;
         esac
+        load_avif=1
     elif test x$enable_avif = xyes; then
         AC_MSG_WARN([*** Unable to find AVIF library (https://github.com/AOMediaCodec/libavif)])
         AC_MSG_WARN([AVIF image loading disabled])
     fi
 fi
+AC_SUBST([LOAD_AVIF], $load_avif)
 
+load_jpg=0
 if test x$enable_jpg = xyes; then
     if test x$enable_stb_image = xyes; then
         AC_DEFINE([LOAD_JPG])
+        load_jpg=1
     elif test x$enable_imageio = xyes; then
         AC_DEFINE([LOAD_JPG])
+        load_jpg=1
         AC_DEFINE([JPG_USES_IMAGEIO])
     else
         PKG_CHECK_MODULES([LIBJPEG], [libjpeg], [dnl
@@ -352,6 +369,7 @@ if test x$enable_jpg = xyes; then
         if test x$have_jpg_hdr = xyes -a x$have_jpg_lib = xyes; then
             if test x$enable_jpg = xyes; then
                 AC_DEFINE([LOAD_JPG])
+                load_jpg=1
             fi
 
             case "$host" in
@@ -374,7 +392,9 @@ if test x$enable_jpg = xyes; then
         fi
     fi
 fi
+AC_SUBST([LOAD_JPG], $load_jpg)
 
+load_jxl=0
 if test x$enable_jxl = xyes; then
     PKG_CHECK_MODULES([LIBJXL], [libjxl], [dnl
         have_jxl_hdr=yes
@@ -393,6 +413,7 @@ if test x$enable_jxl = xyes; then
     if test x$have_jxl_hdr = xyes -a x$have_jxl_lib = xyes; then
         if test x$enable_jxl = xyes; then
             AC_DEFINE([LOAD_JXL])
+            load_jxl=1
         fi
 
         case "$host" in
@@ -414,13 +435,17 @@ if test x$enable_jxl = xyes; then
         AC_MSG_WARN([JXL image loading disabled])
     fi
 fi
+AC_SUBST([LOAD_JXL], $load_jxl)
 
+load_png=0
 if test x$enable_png = xyes; then
     if test x$enable_stb_image = xyes; then
         AC_DEFINE([LOAD_PNG])
+        load_png=1
     elif test x$enable_imageio = xyes; then
         AC_DEFINE([LOAD_PNG])
         AC_DEFINE([PNG_USES_IMAGEIO])
+        load_png=1
     else
         PKG_CHECK_MODULES([LIBPNG], [libpng], [dnl
             have_png_hdr=yes
@@ -438,6 +463,7 @@ if test x$enable_png = xyes; then
           ])
         if test x$have_png_hdr = xyes -a x$have_png_lib = xyes; then
             AC_DEFINE([LOAD_PNG])
+            load_png=1
 
             case "$host" in
                 *-*-darwin*)
@@ -459,7 +485,9 @@ if test x$enable_png = xyes; then
         fi
     fi
 fi
+AC_SUBST([LOAD_PNG], $load_png)
 
+load_tif=0
 if test x$enable_tif = xyes -a x$enable_imageio != xyes; then
     PKG_CHECK_MODULES([LIBTIFF], [libtiff-4], [dnl
         have_tif_hdr=yes
@@ -477,6 +505,7 @@ if test x$enable_tif = xyes -a x$enable_imageio != xyes; then
       ])
     if test x$have_tif_hdr = xyes -a x$have_tif_lib = xyes; then
         AC_DEFINE([LOAD_TIF])
+        load_tif=1
 
         case "$host" in
             *-*-darwin*)
@@ -497,7 +526,9 @@ if test x$enable_tif = xyes -a x$enable_imageio != xyes; then
         AC_MSG_WARN([TIF image loading disabled])
     fi
 fi
+AC_SUBST([LOAD_TIF], $load_tif)
 
+load_webp=0
 if test x$enable_webpdec = xyes; then
   webplib=webpdecoder
 else
@@ -520,6 +551,7 @@ if test x$enable_webp = xyes; then
       ])
     if test x$have_webp_hdr = xyes -a x$have_webp_lib = xyes; then
         AC_DEFINE([LOAD_WEBP])
+        load_webp=1
 
         case "$host" in
             *-*-darwin*)
@@ -540,50 +572,84 @@ if test x$enable_webp = xyes; then
         AC_MSG_WARN([WEBP image loading disabled])
     fi
 fi
+AC_SUBST([LOAD_WEBP], $load_webp)
 
+load_bmp=0
 if test x$enable_bmp = xyes; then
     AC_DEFINE([LOAD_BMP])
+    load_bmp=1
 fi
+AC_SUBST([LOAD_BMP], $load_bmp)
 
+load_gif=0
 if test x$enable_gif = xyes; then
     AC_DEFINE([LOAD_GIF])
+    load_gif=1
 fi
+AC_SUBST([LOAD_GIF], $load_gif)
 
+load_lbm=0
 if test x$enable_lbm = xyes; then
     AC_DEFINE([LOAD_LBM])
+    load_lbm=1
 fi
+AC_SUBST([LOAD_LBM], $load_lbm)
 
+load_pcx=0
 if test x$enable_pcx = xyes; then
     AC_DEFINE([LOAD_PCX])
+    load_pcx=1
 fi
+AC_SUBST([LOAD_PCX], $load_pcx)
 
+load_pnm = 0
 if test x$enable_pnm = xyes; then
     AC_DEFINE([LOAD_PNM])
+    load_pnm=1
 fi
+AC_SUBST([LOAD_PNM], $load_pnm)
 
+load_svg=0
 if test x$enable_svg = xyes; then
     AC_DEFINE([LOAD_SVG])
+    load_svg=1
 fi
+AC_SUBST([LOAD_SVG], $load_svg)
 
+load_tga=0
 if test x$enable_tga = xyes; then
     AC_DEFINE([LOAD_TGA])
+    load_tga=1
 fi
+AC_SUBST([LOAD_TGA], $load_tga)
 
+load_xcf=0
 if test x$enable_xcf = xyes; then
     AC_DEFINE([LOAD_XCF])
+    load_xcf=1
 fi
+AC_SUBST([LOAD_XCF], $load_xcf)
 
+load_xpm=0
 if test x$enable_xpm = xyes; then
     AC_DEFINE([LOAD_XPM])
+    load_xpm=1
 fi
+AC_SUBST([LOAD_XPM], $load_xpm)
 
+load_xv=0
 if test x$enable_xv = xyes; then
     AC_DEFINE([LOAD_XV])
+    load_xv=1
 fi
+AC_SUBST([LOAD_XV], $load_xv)
 
+load_qoi=0
 if test x$enable_qoi = xyes; then
     AC_DEFINE([LOAD_QOI])
+    load_qoi=1
 fi
+AC_SUBST([LOAD_QOI], $load_qoi)
 
 if test x$enable_webp = xyes -a x$have_webp_hdr = xyes -a x$have_webp_lib = xyes; then
     CFLAGS="$LIBWEBP_CFLAGS $CFLAGS"
@@ -676,13 +742,17 @@ if test x$enable_png = xyes -a x$have_png_hdr = xyes -a x$have_png_lib = xyes; t
 fi
 if test x$enable_save_png = xyes; then
     AC_DEFINE([SDL_IMAGE_SAVE_PNG], 1)
+    AC_SUBST([SDL2IMAGE_PNG_SAVE], 1)
 else
     AC_DEFINE([SDL_IMAGE_SAVE_PNG], 0)
+    AC_SUBST([SDL2IMAGE_PNG_SAVE], 0)
 fi
 if test x$enable_save_jpg = xyes; then
     AC_DEFINE([SDL_IMAGE_SAVE_JPG], 1)
+    AC_SUBST([SDL2IMAGE_JPG_SAVE], 1)
 else
     AC_DEFINE([SDL_IMAGE_SAVE_JPG], 0)
+    AC_SUBST([SDL2IMAGE_JPG_SAVE], 0)
 fi
 
 AC_SUBST([IMG_LIBS])
@@ -692,6 +762,12 @@ AC_SUBST([PC_REQUIRES])
 AM_CONDITIONAL([BUILD_TESTS], [test "x$enable_tests" = xyes])
 AM_CONDITIONAL([INSTALL_TESTS], [test "x$enable_installed_tests" = xyes])
 
+dnl Calculate the location of the prefix, relative to the cmake folder
+eval pkg_prefix=$prefix
+eval pkg_cmakedir=$libdir/cmake/SDL2_image
+cmake_prefix_relpath="$(echo -n "$pkg_cmakedir" | sed -E "s#^$pkg_prefix##" | sed -E "s#[A-Za-z0-9_ .-]+#..#g")"
+AC_SUBST([cmake_prefix_relpath])
+
 dnl check for LD --no-undefined option
 CheckNoUndef
 
@@ -706,6 +782,8 @@ OBJCFLAGS=$CFLAGS
 # Finally create all the generated files
 AC_CONFIG_FILES([
 Makefile
+sdl2_image-config.cmake
+sdl2_image-config-version.cmake
 SDL2_image.spec
 SDL2_image.pc
 test/Makefile
diff --git a/sdl2_image-config-version.cmake.in b/sdl2_image-config-version.cmake.in
new file mode 100644
index 00000000..f1c018fb
--- /dev/null
+++ b/sdl2_image-config-version.cmake.in
@@ -0,0 +1,13 @@
+# sdl2_image cmake project-config-version input for ./configure scripts
+
+set(PACKAGE_VERSION "@MAJOR_VERSION_MACRO@.@MINOR_VERSION_MACRO@.@MICRO_VERSION_MACRO@")
+
+if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+  set(PACKAGE_VERSION_COMPATIBLE TRUE)
+  if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+    set(PACKAGE_VERSION_EXACT TRUE)
+  endif()
+endif()
+
diff --git a/sdl2_image-config.cmake.in b/sdl2_image-config.cmake.in
new file mode 100644
index 00000000..da3bec5e
--- /dev/null
+++ b/sdl2_image-config.cmake.in
@@ -0,0 +1,97 @@
+# sdl2_image cmake project-config input for ./configure scripts
+
+include(FeatureSummary)
+set_package_properties(SDL2_image PROPERTIES
+    URL "https://www.libsdl.org/projects/SDL_image/"
+    DESCRIPTION "SDL_image is an image file loading library"
+)
+
+set(SDL2_image_FOUND TRUE)
+
+set(SDL2IMAGE_AVIF  @LOAD_AVIF@)
+set(SDL2IMAGE_BMP   @LOAD_BMP@)
+set(SDL2IMAGE_GIF   @LOAD_GIF@)
+set(SDL2IMAGE_JPG   @LOAD_JPG@)
+set(SDL2IMAGE_JXL   @LOAD_JXL@)
+set(SDL2IMAGE_LBM   @LOAD_LBM@)
+set(SDL2IMAGE_PCX   @LOAD_PCX@)
+set(SDL2IMAGE_PNG   @LOAD_PNG@)
+set(SDL2IMAGE_PNM   @LOAD_PNM@)
+set(SDL2IMAGE_QOI   @LOAD_QOI@)
+set(SDL2IMAGE_SVG   @LOAD_SVG@)
+set(SDL2IMAGE_TGA   @LOAD_TGA@)
+set(SDL2IMAGE_TIF   @LOAD_TIF@)
+set(SDL2IMAGE_XCF   @LOAD_XCF@)
+set(SDL2IMAGE_XPM   @LOAD_XPM@)
+set(SDL2IMAGE_XV    @LOAD_XV@)
+set(SDL2IMAGE_WEBP  @LOAD_WEBP@)
+
+set(SDL2IMAGE_JPG_SAVE @SDL2IMAGE_JPG_SAVE@)
+set(SDL2IMAGE_PNG_SAVE @SDL2IMAGE_PNG_SAVE@)
+
+set(SDL2IMAGE_VENDORED  FALSE)
+
+set(SDL2IMAGE_BACKEND_IMAGEIO   @USE_IMAGEIO@)
+set(SDL2IMAGE_BACKEND_STB       @USE_STBIMAGE@)
+set(SDL2IMAGE_BACKEND_WIC       @USE_WIC@)
+
+get_filename_component(prefix "${CMAKE_CURRENT_LIST_DIR}@cmake_prefix_relpath@" ABSOLUTE)
+set(exec_prefix "@exec_prefix@")
+set(bindir "@bindir@")
+set(includedir "@includedir@")
+set(libdir "@libdir@")
+set(_sdl2image_extra_static_libraries "@IMG_LIBS@ @PC_LIBS@")
+string(STRIP "${_sdl2image_extra_static_libraries}" _sdl2image_extra_static_libraries)
+
+set(_sdl2image_bindir   "${bindir}")
+set(_sdl2image_libdir   "${libdir}")
+set(_sdl2image_incdir   "${includedir}/SDL2")
+
+# Convert _sdl2image_extra_static_libraries to list and keep only libraries
+string(REGEX MATCHALL "(-[lm]([a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2image_extra_static_libraries "${_sdl2image_extra_static_libraries}")
+string(REGEX REPLACE "^-l" "" _sdl2image_extra_static_libraries "${_sdl2image_extra_static_libraries}")
+string(REGEX REPLACE ";-l" ";" _sdl2image_extra_static_libraries "${_sdl2image_extra_static_libraries}")
+
+unset(prefix)
+unset(exec_prefix)
+unset(bindir)
+unset(includedir)
+unset(libdir)
+
+include(CMakeFindDependencyMacro)
+
+if(NOT TARGET SDL2_image::SDL2_image)
+    add_library(SDL2_image::SDL2_image SHARED IMPORTED)
+    set_target_properties(SDL2_image::SDL2_image
+        PROPERTIES
+            INTERFACE_INCLUDE_DIRECTORIES "${_sdl2image_incdir}"
+    )
+    if(WIN32)
+        set_target_properties(SDL2_image::SDL2_image
+            PROPERTIES
+                IMPORTED_LOCATION "${_sdl2image_bindir}/SDL2_image.dll"
+                IMPORTED_IMPLIB "${_sdl2image_libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_image.dll${CMAKE_STATIC_LIBRARY_SUFFIX}"
+        )
+    else()
+        set_target_properties(SDL2_image::SDL2_image
+            PROPERTIES
+                IMPORTED_LOCATION "${_sdl2image_libdir}/${CMAKE_SHARED_LIBRARY_PREFIX}SDL2_image${CMAKE_SHARED_LIBRARY_SUFFIX}"
+        )
+    endif()
+endif()
+
+if(NOT TARGET SDL2_image::SDL2_image-static)
+    add_library(SDL2_image::SDL2_image-static STATIC IMPORTED)
+
+    set_target_properties(SDL2_image::SDL2_image-static
+        PROPERTIES
+            INTERFACE_INCLUDE_DIRECTORIES "${_sdl2image_incdir}"
+            IMPORTED_LOCATION "${_sdl2image_libdir}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2_image${CMAKE_STATIC_LIBRARY_SUFFIX}"
+            INTERFACE_LINK_LIBRARIES "

(Patch may be truncated, please check the link at the top of this post.)