diff options
author | Jeremie Guichard <djebrest@gmail.com> | 2017-03-09 23:07:30 +0700 |
---|---|---|
committer | Jeremie Guichard <djebrest@gmail.com> | 2017-03-09 23:07:30 +0700 |
commit | 2b06a0b2234cf2779f80e87038011067be282bcb (patch) | |
tree | 7532b11736a5eaedb3ceddf3e85ee423948d47ce /CMakeLists.txt | |
parent | 406e4287eb96e10ddfd22163f0e863e353470c68 (diff) | |
download | subsurface-2b06a0b2234cf2779f80e87038011067be282bcb.tar.gz |
Fix potential double/float to int rounding errors
Not using lrint(f) when converting double/float to int
creates rounding errors.
This error was detected by TestParse::testParseDM4 failure
on Windows. It was creating rounding inconsistencies
on Linux too, see change in TestDiveDM4.xml.
Enable -Wfloat-conversion for gcc version greater than 4.9.0
Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9998b76d2..3123fca5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,14 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + + # Warn about possible float conversion errors + # Use NOT VERSION_LESS since VERSION_GREATER_EQUAL is not available + # in currently used cmake version. + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9.0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-conversion") + endif() + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") # using Intel C++ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") |