SDL_image: cmake: we should only disallow static SDL2 + shared SDL2_image

From 6426bcd7796e17a0353c62519d30e6fcdab19400 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Mon, 30 May 2022 00:34:41 +0200
Subject: [PATCH] cmake: we should only disallow static SDL2 + shared
 SDL2_image

---
 CMakeLists.txt | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 78fcfee8..896728cf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -263,9 +263,11 @@ if(SDL2IMAGE_BUILD_SHARED_LIBS)
     endif()
 endif()
 
-# Use `Compatible Interface Properties` to ensure all linked SDL2 libraries are built with the same "sharedness".
-set_property(TARGET SDL2_image PROPERTY INTERFACE_SDL2_SHARED ${SDL2IMAGE_BUILD_SHARED_LIBS})
-set_property(TARGET SDL2_image APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL2_SHARED)
+# Use `Compatible Interface Properties` to ensure a shared SDL2_image is built with a shared SDL2
+if(SDL2IMAGE_BUILD_SHARED_LIBS)
+    set_property(TARGET SDL2_image PROPERTY INTERFACE_SDL2_SHARED ${SDL2IMAGE_BUILD_SHARED_LIBS})
+    set_property(TARGET SDL2_image APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL2_SHARED)
+endif()
 
 if(SDL2IMAGE_BUILD_SHARED_LIBS)
     sdl_target_link_options_no_undefined(SDL2_image)