From 732b003b8d69dd18dcd3e8eb496ec02d44241ff2 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Sun, 10 Feb 2019 19:14:04 +0100 Subject: [PATCH] Add -msse2 to compile flags on x86 only if necessary --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20e46dd55..8f0e0c71d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,11 +145,18 @@ if(NOT MSVC) # Inaccurate floating point numbers cause problems on mingw-w64-gcc when # compiling for x86, might cause problems elsewhere. So don't store floats # in registers but keep them at higher accuracy. - if(TARGET_ARCH STREQUAL "x86") add_c_compiler_flag_if_supported(OUR_FLAGS -ffloat-store) endif() + # gcc < 4.10 chokes on _mm_pause on x86 without SSE support. + if(TARGET_ARCH STREQUAL "x86") + check_c_source_compiles("#include \nint main() { _mm_pause(); return 0; }" MM_PAUSE_WORKS_WITHOUT_MSSE2) + if(NOT MM_PAUSE_WORKS_WITHOUT_MSSE2) + add_c_compiler_flag_if_supported(OUR_FLAGS -msse2) + endif() + endif() + if(TARGET_OS STREQUAL "mac") add_c_compiler_flag_if_supported(OUR_FLAGS -stdlib=libc++) add_c_compiler_flag_if_supported(OUR_FLAGS -mmacosx-version-min=10.7)