SDL: tests: build tests with fast math disabled

From 9d6b028e011a122764f080d18879ffbf1f677e79 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Mon, 7 Aug 2023 22:39:47 +0200
Subject: [PATCH] tests: build tests with fast math disabled

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

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 82bb2da4e3a9..1aae3576c8f5 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -46,6 +46,13 @@ macro(add_sdl_test_executable TARGET)
             target_compile_options(${TARGET} PRIVATE "/clang:-fcomment-block-commands=deprecated")
         endif()
     endif()
+
+    if(USE_GCC OR USE_CLANG)
+        check_c_compiler_flag(-fno-fast-math HAVE_GCC_FNO_FAST_MATH)
+        if(HAVE_GCC_FNO_FAST_MATH)
+            target_compile_options(${TARGET} PRIVATE -fno-fast-math)
+        endif()
+    endif()
 endmacro()
 
 if(NOT TARGET SDL2::SDL2-static)