aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-03-18 20:05:15 -0700
committerChris Robinson <[email protected]>2019-03-18 20:05:15 -0700
commit6a0b2ed0ca2b7628771ee450567c2c62c575db36 (patch)
tree9d44a86dc6b92fa79d3907311b81c0b705f665a8 /CMakeLists.txt
parent821c7565cf1051e23eb85428076dcef991b69802 (diff)
Check compile-time support for SSE intrinsics
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt31
1 files changed, 23 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 67369d78..9f0dc8ed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -386,6 +386,13 @@ IF(HAVE_MFPU_NEON_SWITCH)
SET(FPU_NEON_SWITCH "-mfpu=neon")
ENDIF()
+CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE2_SWITCH}")
+CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}")
+CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}")
+CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}")
+CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H "${FPU_NEON_SWITCH}")
+
+SET(SSE_FLAGS )
SET(FPMATH_SET "0")
IF(CMAKE_SIZEOF_VOID_P MATCHES "4")
IF(SSE2_SWITCH OR MSVC)
@@ -396,19 +403,33 @@ IF(CMAKE_SIZEOF_VOID_P MATCHES "4")
IF(SSE2_SWITCH)
CHECK_C_COMPILER_FLAG("${SSE2_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE_2)
IF(HAVE_MFPMATH_SSE_2)
- SET(C_FLAGS ${C_FLAGS} ${SSE2_SWITCH} -mfpmath=sse)
+ SET(SSE_FLAGS ${SSE_FLAGS} ${SSE2_SWITCH} -mfpmath=sse)
+ SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
SET(FPMATH_SET 2)
ENDIF()
ELSEIF(MSVC)
CHECK_C_COMPILER_FLAG("/arch:SSE2" HAVE_ARCH_SSE2)
IF(HAVE_ARCH_SSE2)
- SET(C_FLAGS ${C_FLAGS} "/arch:SSE2")
+ SET(SSE_FLAGS ${SSE_FLAGS} "/arch:SSE2")
+ SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS})
SET(FPMATH_SET 2)
ENDIF()
ENDIF()
ENDIF()
ENDIF()
+IF(HAVE_EMMINTRIN_H)
+ SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ FOREACH(flag_var ${SSE_FLAGS})
+ SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag_var}")
+ ENDFOREACH()
+
+ CHECK_C_SOURCE_COMPILES("#include <emmintrin.h>
+ int main() {_mm_pause(); return 0;}" HAVE_SSE_INTRINSICS)
+
+ SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
+ENDIF()
+
CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));
int main() {return 0;}" HAVE_GCC_FORMAT)
@@ -723,12 +744,6 @@ SET(HAVE_SSE3 0)
SET(HAVE_SSE4_1 0)
SET(HAVE_NEON 0)
-CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE2_SWITCH}")
-CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}")
-CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}")
-CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}")
-CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H "${FPU_NEON_SWITCH}")
-
# Check for SSE+SSE2 support
OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF)
OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF)