SDL_image: cmake: optionally look for SDL2::SDL2main and SDL2::SDL2test in test/CMakeLists.txt

From eae3238b5e30ac0c83ad3bcf7f0a2c84d5913e23 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 30 Jun 2023 22:33:20 +0200
Subject: [PATCH] cmake: optionally look for SDL2::SDL2main and SDL2::SDL2test
 in test/CMakeLists.txt

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

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 688a7239..45c8c532 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,5 +1,10 @@
-find_package(SDL2main)
-find_package(SDL2test REQUIRED)
+if(NOT TARGET SDL2::SDL2main)
+    find_package(SDL2main)
+endif()
+
+if(NOT TARGET SDL2::SDL2test)
+    find_package(SDL2test REQUIRED)
+endif()
 
 add_executable(testimage main.c)