SDL_image: cmake: install(CODE) does not support CONFIG/CONFIGURATIONS keyword argument

From b8b25211ab36f498af0592a76f0a547e5a79d7c2 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 22 Jul 2022 19:03:21 +0200
Subject: [PATCH] cmake: install(CODE) does not support CONFIG/CONFIGURATIONS
 keyword argument

---
 CMakeLists.txt | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cecc9815..71a85f75 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -717,13 +717,15 @@ if(SDL2IMAGE_INSTALL)
         endif()
         # Only install a SDL2_image.pc file in Release mode
         install(CODE "
-            # FIXME: use file(COPY_FILE) if minimum CMake version >= 3.21
-            execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy_if_different
-                \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_image-$<CONFIG>.pc\"
-                \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_image.pc\")
-            file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${PC_DESTDIR}\"
-                TYPE FILE
-                FILES \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_image.pc\")" CONFIG Release COMPONENT devel)
+            if(CMAKE_INSTALL_CONFIG_NAME MATCHES \"Release\")
+                # FIXME: use file(COPY_FILE) if minimum CMake version >= 3.21
+                execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy_if_different
+                    \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_image-$<CONFIG>.pc\"
+                    \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_image.pc\")
+                file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${PC_DESTDIR}\"
+                    TYPE FILE
+                    FILES \"${CMAKE_CURRENT_BINARY_DIR}/SDL2_image.pc\")
+            endif()" COMPONENT devel)
     endif()
 
     if(SDL2IMAGE_BUILD_SHARED_LIBS AND (APPLE OR (UNIX AND NOT ANDROID)))