Skip to content

Commit f05b27f

Browse files
committed
cmake: add USE_FAST_MATH to enable or disable fast math
1 parent ad7b69c commit f05b27f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cmake/DaemonFlags.cmake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ else()
148148
set(WARNMODE "no-")
149149
endif()
150150

151+
option(USE_FAST_MATH "Use fast math" ON)
152+
151153
option(USE_DEBUG_FPE "Use floating point exceptions" OFF)
152154

153155
if (USE_DEBUG_FPE)
@@ -157,7 +159,11 @@ endif()
157159
# Compiler options
158160
if (MSVC)
159161
set_c_cxx_flag("/MP")
160-
set_c_cxx_flag("/fp:fast")
162+
163+
if (USE_FAST_MATH)
164+
set_c_cxx_flag("/fp:fast")
165+
endif()
166+
161167
set_c_cxx_flag("/d2Zi+" RELWITHDEBINFO)
162168

163169
# https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
@@ -244,7 +250,9 @@ else()
244250
endif()
245251

246252
# Optimizations.
247-
set_c_cxx_flag("-ffast-math")
253+
if (USE_FAST_MATH)
254+
set_c_cxx_flag("-ffast-math")
255+
endif()
248256

249257
if (USE_DEBUG_FPE)
250258
# Floating point exceptions requires trapping math

0 commit comments

Comments
 (0)