Force SSE2 floats for i686 targets

Both GCC and Clang use x87 instructions by default on 32-bit x86
targets, but the loss of precision resulting from that has yielded
crashing tests (see referenced issue), and it can be safely assumed
there are very few CPUs that both don't support SSE2 and are expected to
run SolveSpace

This commit also removes a now-redundant check for 32-bit Windows
against TARGET, which doesn't seem to be actually set by CMake at all

Ref: #565
pull/572/head
nabijaczleweli 2020-03-24 13:04:06 +01:00 committed by whitequark
parent aeaece53e1
commit 645353cbdc
1 changed files with 12 additions and 3 deletions

View File

@ -80,11 +80,20 @@ endif()
if(MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
endif()
if(TRIPLE STREQUAL "i686-w64-mingw32")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
# Ensure that all platforms use 64-bit IEEE floating point operations for consistency;
# this is most important for the testsuite, which compares savefiles directly
# and depends on consistent rounding of intermediate results.
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "X86")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(FLOAT_FLAGS "-mfpmath=sse -msse2")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(FLOAT_FLAGS "-msse2")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLOAT_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLOAT_FLAGS}")
endif()
if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")