shithub: opus

Download patch

ref: 7f035cc695247b7392990963a265d03f17791ab1
parent: c5c986a3a9d3035b4813998a5f903b6758c456c9
author: Marcus Asteborg <maastebo@microsoft.com>
date: Mon Apr 13 12:14:49 EDT 2020

cmake - add option for fast math

Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,6 +59,20 @@
                        "NOT OPUS_VAR_ARRAYS; NOT OPUS_USE_ALLOCA"
                        OFF)
 
+cmake_dependent_option(OPUS_FAST_MATH
+                       "Enable fast math"
+                       ON
+                       "OPUS_FLOAT_APPROX; OPUS_FAST_MATH"
+                       OFF)
+
+if(OPUS_FAST_MATH)
+  if(MSVC)
+    check_and_set_flag(FAST_MATH /fp:fast)
+  else()
+    check_and_set_flag(FAST_MATH -ffast-math)
+  endif()
+endif()
+
 if(OPUS_BUILD_SHARED_LIBRARY OR BUILD_SHARED_LIBS)
   # Global flag to cause add_library() to create shared libraries if on.
   set(BUILD_SHARED_LIBS ON)
@@ -176,6 +190,7 @@
   "compile with the floating point API (for machines with float library)")
 add_feature_info(OPUS_FLOAT_APPROX OPUS_FLOAT_APPROX
   "Enable floating point approximations (Ensure your platform supports IEEE 754 before enabling)")
+add_feature_info(OPUS_FAST_MATH FAST_MATH_SUPPORTED "Enable fast math, (depending on OPUS_FLOAT_APPROX to be enabled)")
 add_feature_info(OPUS_INSTALL_PKG_CONFIG_MODULE OPUS_INSTALL_PKG_CONFIG_MODULE
                  "install PkgConfig module")
 add_feature_info(OPUS_INSTALL_CMAKE_CONFIG_MODULE OPUS_INSTALL_CMAKE_CONFIG_MODULE