SDL_image: Tests: Copy resources to binary directory after build

From 20de661a757b36db81abc60807b7fc729982cd19 Mon Sep 17 00:00:00 2001
From: Petar Popovic <[EMAIL REDACTED]>
Date: Sun, 19 Apr 2026 18:42:11 +0200
Subject: [PATCH] Tests: Copy resources to binary directory after build

---
 test/CMakeLists.txt | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 7262e1000..2c20f3481 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -98,6 +98,17 @@ function(add_sdl_image_test NAME)
     endif()
 endfunction()
 
+function(copy_sdl_image_test_resources TARGET)
+    foreach(res_file_name IN LISTS RESOURCE_FILES)
+        set(resource_file "${CMAKE_CURRENT_SOURCE_DIR}/${res_file_name}")
+        set(resource_file_bindir "${CMAKE_CURRENT_BINARY_DIR}/${res_file_name}")
+
+        add_custom_command(TARGET ${TARGET} POST_BUILD
+            COMMAND "${CMAKE_COMMAND}" -E copy "${resource_file}" "${resource_file_bindir}"
+        )
+    endforeach()
+endfunction()
+
 add_sdl_image_test_executable(testimage testimage.c)
 add_sdl_image_test_executable(testanimation testanimation.c)
 
@@ -105,6 +116,8 @@ add_sdl_image_test(testimage COMMAND testimage)
 add_sdl_image_test(testanimation_dummy_metadata COMMAND testanimation)
 add_sdl_image_test(testanimation COMMAND testanimation --no-dummy-metadata)
 
+copy_sdl_image_test_resources(testimage)
+
 if(SDLIMAGE_TESTS_INSTALL)
     install(
         FILES ${RESOURCE_FILES}