SDL_gpu_shadercross: Don't find SDL3::Headers and SDL3::SDL3{-shared} if the targets exists already

From 1d60b244383689790f9b35a55ee6cab8c42e2bb9 Mon Sep 17 00:00:00 2001
From: Alex Young <[EMAIL REDACTED]>
Date: Mon, 4 Nov 2024 23:45:21 +0100
Subject: [PATCH] Don't find SDL3::Headers and SDL3::SDL3{-shared} if the
 targets exists already

---
 CMakeLists.txt | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5964cfd..9b878d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,9 @@ include("${CMAKE_CURRENT_LIST_DIR}/cmake/PrivateSdlFunctions.cmake")
 include("${CMAKE_CURRENT_LIST_DIR}/cmake/sdlcpu.cmake")
 include("${CMAKE_CURRENT_LIST_DIR}/cmake/sdlplatform.cmake")
 
-find_package(SDL3 REQUIRED COMPONENTS SDL3-shared)
+if(NOT TARGET SDL3::Headers OR NOT TARGET SDL3::SDL3-shared)
+    find_package(SDL3 ${SDL_REQUIRED_VERSION} REQUIRED COMPONENTS Headers SDL3-shared)
+endif()
 
 if(BUILD_SHARED_LIBS)
 	set(SDLGPUSHADERCROSS_SHARED_DEFAULT ON)
@@ -104,7 +106,9 @@ endif()
 
 if(SDLGPUSHADERCROSS_STATIC)
 	list(APPEND SDL3_gpu_shadercross_targets SDL3_gpu_shadercross-static)
-	find_package(SDL3 REQUIRED COMPONENTS Headers)
+	if(NOT TARGET SDL3::Headers OR NOT TARGET SDL3::SDL3)
+		find_package(SDL3 ${SDL_REQUIRED_VERSION} REQUIRED COMPONENTS Headers)
+	endif()
 
 	add_library(SDL3_gpu_shadercross-static STATIC ${SOURCE_FILES})
 	add_library(SDL3_gpu_shadercross::SDL3_gpu_shadercross-static ALIAS SDL3_gpu_shadercross-static)