From 2d92f42878f45e023c5ae4e8e9c570283a084f6f Mon Sep 17 00:00:00 2001
From: Alexander Smorkalov <alexander.smorkalov@xperience.ai>
Date: Wed, 5 Jul 2023 16:08:33 +0300
Subject: [PATCH] Disable finite-math-only option with ENABLE_FAST_MATH=1 case
 to handle NaN and Inf checks correctly.

---
 cmake/OpenCVCompilerOptions.cmake | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake
index 3f3358aae5..d4600943fb 100644
--- a/cmake/OpenCVCompilerOptions.cmake
+++ b/cmake/OpenCVCompilerOptions.cmake
@@ -108,6 +108,7 @@ elseif(CV_ICC)
 elseif(CV_GCC OR CV_CLANG)
   if(ENABLE_FAST_MATH)
     add_extra_compiler_option(-ffast-math)
+    add_extra_compiler_option(-fno-finite-math-only)
   endif()
 endif()