SDL_image: Create a PDB symbol file when building with Visual Studio

From 236bdd9a82b02d40d5fddad26afbf9ff82d015ae Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 26 Jan 2024 13:15:44 -0800
Subject: [PATCH] Create a PDB symbol file when building with Visual Studio

---
 CMakeLists.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d46cab69..495716dc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -289,6 +289,21 @@ set_target_properties(${sdl3_image_target_name} PROPERTIES
     C_VISIBILITY_PRESET "hidden"
 )
 
+if (MSVC  AND CMAKE_BUILD_TYPE MATCHES "Release")
+   target_compile_options(${sdl3_image_target_name} PRIVATE /Zi)
+
+   # Tell linker to include symbol data
+    set_target_properties(${sdl3_image_target_name} PROPERTIES
+        LINK_FLAGS "/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF"
+    )
+
+    # Set file name & location
+    set_target_properties(${sdl3_image_target_name} PROPERTIES
+        COMPILE_PDB_NAME ${sdl3_image_target_name}
+        COMPILE_PDB_OUTPUT_DIR ${CMAKE_BINARY_DIR}
+    )
+endif()
+
 sdl_target_link_option_version_file(${sdl3_image_target_name} "${CMAKE_CURRENT_SOURCE_DIR}/src/SDL_image.sym")
 
 if(NOT ANDROID)