SDL_image: cmake: only do find_package(SDL3) when SDL3 target is not available

From f6d3e70b8478ba298ebfefdcdbc1b34084ba2195 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 6 Jan 2023 14:03:12 +0100
Subject: [PATCH] cmake: only do find_package(SDL3) when SDL3 target is not
 available

---
 CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a77be9d3..d6f4382d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -162,7 +162,9 @@ else()
     set(sdl3_target_name SDL3::SDL3-static)
 endif()
 
-find_package(SDL3 ${SDL_REQUIRED_VERSION} REQUIRED)
+if(NOT TARGET ${sdl3_target_name})
+    find_package(SDL3 ${SDL_REQUIRED_VERSION} REQUIRED)
+endif()
 
 # Set PROJECT_VERSION of subprojects to "" if it's project call does not set VERSION
 cmake_policy(SET CMP0048 NEW)