]> git.lizzy.rs Git - irrlicht.git/commitdiff
Automatically use SSE registers for FP operations on i386 (#83)
authorWilliam L. DeRieux IV <williamderieux@gmail.com>
Sat, 11 Dec 2021 11:43:23 +0000 (06:43 -0500)
committersfan5 <sfan5@live.de>
Wed, 15 Dec 2021 15:33:20 +0000 (16:33 +0100)
source/Irrlicht/CMakeLists.txt

index 961e55416d87090c93700d5fe65a08e978e1f77f..81de8570720bced39cefde00d1211db5b79d83e5 100644 (file)
@@ -18,10 +18,28 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
        set(CMAKE_CXX_FLAGS_DEBUG "-g")
 
        add_compile_options(-Wall -pipe -fno-exceptions -fno-rtti)
+
+       # Enable SSE for floating point math on 32-bit x86 by default
+       # reasoning see minetest issue #11810 and https://gcc.gnu.org/wiki/FloatingPointMath
+       if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+               include(CheckCXXSourceCompiles)
+               check_cxx_source_compiles("#ifndef __i686__\n#error\n#endif\nint main(){}" IS_I686)
+               if(IS_I686)
+                       message(STATUS "Detected Intel x86: using SSE instead of x87 FPU")
+                       add_compile_options(-mfpmath=sse -msse)
+               endif()
+       endif()
+
 elseif(MSVC)
        string(APPEND CMAKE_CXX_STANDARD_LIBRARIES " msvcrt.lib") # ???? fuck off
 
        add_compile_options(/GR- /Zl)
+
+       # Enable SSE for floating point math on 32-bit x86 by default
+       # reasoning see minetest issue #11810 and https://gcc.gnu.org/wiki/FloatingPointMath
+       if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+               add_compile_options(/arch:SSE)
+       endif()
 endif()
 
 # Required libs