SDL_image: cmake: use CheckLinkerFlag (b3ede)

From b3ededb8a410b6ccfcd5cdc5c080ce72340cfc1d Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 8 Jan 2026 21:13:06 +0100
Subject: [PATCH] cmake: use CheckLinkerFlag

(cherry picked from commit 4c2a559812020a77c3302caf8a8287294f1c719b)
---
 cmake/PrivateSdlFunctions.cmake | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/cmake/PrivateSdlFunctions.cmake b/cmake/PrivateSdlFunctions.cmake
index 117e3c4c..acdb5a40 100644
--- a/cmake/PrivateSdlFunctions.cmake
+++ b/cmake/PrivateSdlFunctions.cmake
@@ -3,6 +3,9 @@
 include(CheckCCompilerFlag)
 include(CheckCSourceCompiles)
 include(CMakePushCheckState)
+if(NOT CMAKE_VERSION VERSION_LESS "3.18")
+  include(CheckLinkerFlag)
+endif()
 
 macro(sdl_calculate_derived_version_variables MAJOR MINOR MICRO)
     set(SO_VERSION_MAJOR "0")
@@ -241,11 +244,14 @@ function(sdl_check_project_in_subfolder relative_subfolder name vendored_option)
 endfunction()
 
 macro(sdl_check_linker_flag flag var)
-    # FIXME: Use CheckLinkerFlag module once cmake minimum version >= 3.18
-    cmake_push_check_state(RESET)
-    set(CMAKE_REQUIRED_LINK_OPTIONS "${flag}")
-    check_c_source_compiles("int main() { return 0; }" ${var} FAIL_REGEX "(unsupported|syntax error|unrecognized option)")
-    cmake_pop_check_state()
+    if(NOT CMAKE_VERSION VERSION_LESS "3.18")
+        check_linker_flag(C "${flag}" "${var}")
+    else()
+        cmake_push_check_state(RESET)
+        set(CMAKE_REQUIRED_LINK_OPTIONS "${flag}")
+        check_c_source_compiles("int main() { return 0; }" ${var} FAIL_REGEX "(unsupported|syntax error|unrecognized option)")
+        cmake_pop_check_state()
+    endif()
 endmacro()
 
 function(SDL_detect_linker)