|
@@ -0,0 +1,124 @@
|
|
1
|
+# Check if SSE instructions are available on the machine where
|
|
2
|
+# the project is compiled.
|
|
3
|
+
|
|
4
|
+IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
5
|
+ EXEC_PROGRAM(cat ARGS "/proc/cpuinfo" OUTPUT_VARIABLE CPUINFO)
|
|
6
|
+
|
|
7
|
+ # TODO
|
|
8
|
+ set(SSE_FOUND true CACHE BOOL "SSE available on host")
|
|
9
|
+
|
|
10
|
+ STRING(REGEX REPLACE "^.*(sse2).*$" "\\1" SSE_THERE ${CPUINFO})
|
|
11
|
+ STRING(COMPARE EQUAL "sse2" "${SSE_THERE}" SSE2_TRUE)
|
|
12
|
+ IF (SSE2_TRUE)
|
|
13
|
+ set(SSE2_FOUND true CACHE BOOL "SSE2 available on host")
|
|
14
|
+ ELSE (SSE2_TRUE)
|
|
15
|
+ set(SSE2_FOUND false CACHE BOOL "SSE2 available on host")
|
|
16
|
+ ENDIF (SSE2_TRUE)
|
|
17
|
+
|
|
18
|
+ # /proc/cpuinfo apparently omits sse3 :(
|
|
19
|
+ STRING(REGEX REPLACE "^.*[^s](sse3).*$" "\\1" SSE_THERE ${CPUINFO})
|
|
20
|
+ STRING(COMPARE EQUAL "sse3" "${SSE_THERE}" SSE3_TRUE)
|
|
21
|
+ IF (NOT SSE3_TRUE)
|
|
22
|
+ STRING(REGEX REPLACE "^.*(T2300).*$" "\\1" SSE_THERE ${CPUINFO})
|
|
23
|
+ STRING(COMPARE EQUAL "T2300" "${SSE_THERE}" SSE3_TRUE)
|
|
24
|
+ ENDIF (NOT SSE3_TRUE)
|
|
25
|
+
|
|
26
|
+ STRING(REGEX REPLACE "^.*(ssse3).*$" "\\1" SSE_THERE ${CPUINFO})
|
|
27
|
+ STRING(COMPARE EQUAL "ssse3" "${SSE_THERE}" SSSE3_TRUE)
|
|
28
|
+ IF (SSE3_TRUE OR SSSE3_TRUE)
|
|
29
|
+ set(SSE3_FOUND true CACHE BOOL "SSE3 available on host")
|
|
30
|
+ ELSE (SSE3_TRUE OR SSSE3_TRUE)
|
|
31
|
+ set(SSE3_FOUND false CACHE BOOL "SSE3 available on host")
|
|
32
|
+ ENDIF (SSE3_TRUE OR SSSE3_TRUE)
|
|
33
|
+ IF (SSSE3_TRUE)
|
|
34
|
+ set(SSSE3_FOUND true CACHE BOOL "SSSE3 available on host")
|
|
35
|
+ ELSE (SSSE3_TRUE)
|
|
36
|
+ set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host")
|
|
37
|
+ ENDIF (SSSE3_TRUE)
|
|
38
|
+
|
|
39
|
+ STRING(REGEX REPLACE "^.*(sse4_1).*$" "\\1" SSE_THERE ${CPUINFO})
|
|
40
|
+ STRING(COMPARE EQUAL "sse4_1" "${SSE_THERE}" SSE41_TRUE)
|
|
41
|
+ IF (SSE41_TRUE)
|
|
42
|
+ set(SSE4_1_FOUND true CACHE BOOL "SSE4.1 available on host")
|
|
43
|
+ ELSE (SSE41_TRUE)
|
|
44
|
+ set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host")
|
|
45
|
+ ENDIF (SSE41_TRUE)
|
|
46
|
+ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|
47
|
+ EXEC_PROGRAM("/usr/sbin/sysctl -n machdep.cpu.features" OUTPUT_VARIABLE
|
|
48
|
+ CPUINFO)
|
|
49
|
+
|
|
50
|
+ STRING(REGEX REPLACE "^.*[^S](SSE).*$" "\\1" SSE_THERE ${CPUINFO})
|
|
51
|
+ STRING(COMPARE EQUAL "SSE" "${SSE_THERE}" SSE_TRUE)
|
|
52
|
+ IF (SSE_TRUE)
|
|
53
|
+ set(SSE_FOUND true CACHE BOOL "SSE available on host")
|
|
54
|
+ ELSE (SSE_TRUE)
|
|
55
|
+ set(SSE_FOUND false CACHE BOOL "SSE available on host")
|
|
56
|
+ ENDIF (SSE_TRUE)
|
|
57
|
+
|
|
58
|
+ STRING(REGEX REPLACE "^.*[^S](SSE2).*$" "\\1" SSE_THERE ${CPUINFO})
|
|
59
|
+ STRING(COMPARE EQUAL "SSE2" "${SSE_THERE}" SSE2_TRUE)
|
|
60
|
+ IF (SSE2_TRUE)
|
|
61
|
+ set(SSE2_FOUND true CACHE BOOL "SSE2 available on host")
|
|
62
|
+ ELSE (SSE2_TRUE)
|
|
63
|
+ set(SSE2_FOUND false CACHE BOOL "SSE2 available on host")
|
|
64
|
+ ENDIF (SSE2_TRUE)
|
|
65
|
+
|
|
66
|
+ STRING(REGEX REPLACE "^.*[^S](SSE3).*$" "\\1" SSE_THERE ${CPUINFO})
|
|
67
|
+ STRING(COMPARE EQUAL "SSE3" "${SSE_THERE}" SSE3_TRUE)
|
|
68
|
+ IF (SSE3_TRUE)
|
|
69
|
+ set(SSE3_FOUND true CACHE BOOL "SSE3 available on host")
|
|
70
|
+ ELSE (SSE3_TRUE)
|
|
71
|
+ set(SSE3_FOUND false CACHE BOOL "SSE3 available on host")
|
|
72
|
+ ENDIF (SSE3_TRUE)
|
|
73
|
+
|
|
74
|
+ STRING(REGEX REPLACE "^.*(SSSE3).*$" "\\1" SSE_THERE ${CPUINFO})
|
|
75
|
+ STRING(COMPARE EQUAL "SSSE3" "${SSE_THERE}" SSSE3_TRUE)
|
|
76
|
+ IF (SSSE3_TRUE)
|
|
77
|
+ set(SSSE3_FOUND true CACHE BOOL "SSSE3 available on host")
|
|
78
|
+ ELSE (SSSE3_TRUE)
|
|
79
|
+ set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host")
|
|
80
|
+ ENDIF (SSSE3_TRUE)
|
|
81
|
+
|
|
82
|
+ STRING(REGEX REPLACE "^.*(SSE4.1).*$" "\\1" SSE_THERE ${CPUINFO})
|
|
83
|
+ STRING(COMPARE EQUAL "SSE4.1" "${SSE_THERE}" SSE41_TRUE)
|
|
84
|
+ IF (SSE41_TRUE)
|
|
85
|
+ set(SSE4_1_FOUND true CACHE BOOL "SSE4.1 available on host")
|
|
86
|
+ ELSE (SSE41_TRUE)
|
|
87
|
+ set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host")
|
|
88
|
+ ENDIF (SSE41_TRUE)
|
|
89
|
+ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
90
|
+ # TODO
|
|
91
|
+ set(SSE_FOUND true CACHE BOOL "SSE available on host")
|
|
92
|
+ set(SSE2_FOUND true CACHE BOOL "SSE2 available on host")
|
|
93
|
+ set(SSE3_FOUND false CACHE BOOL "SSE3 available on host")
|
|
94
|
+ set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host")
|
|
95
|
+ set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host")
|
|
96
|
+ELSE(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
97
|
+ set(SSE_FOUND true CACHE BOOL "SSE available on host")
|
|
98
|
+ set(SSE2_FOUND true CACHE BOOL "SSE2 available on host")
|
|
99
|
+ set(SSE3_FOUND false CACHE BOOL "SSE3 available on host")
|
|
100
|
+ set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host")
|
|
101
|
+ set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host")
|
|
102
|
+ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
103
|
+
|
|
104
|
+if(NOT SSE_FOUND)
|
|
105
|
+ MESSAGE(STATUS "Could not find hardware support for SSE on this machine.")
|
|
106
|
+endif(NOT SSE_FOUND)
|
|
107
|
+
|
|
108
|
+if(NOT SSE2_FOUND)
|
|
109
|
+ MESSAGE(STATUS "Could not find hardware support for SSE2 on this machine.")
|
|
110
|
+endif(NOT SSE2_FOUND)
|
|
111
|
+
|
|
112
|
+if(NOT SSE3_FOUND)
|
|
113
|
+ MESSAGE(STATUS "Could not find hardware support for SSE3 on this machine.")
|
|
114
|
+endif(NOT SSE3_FOUND)
|
|
115
|
+
|
|
116
|
+if(NOT SSSE3_FOUND)
|
|
117
|
+ MESSAGE(STATUS "Could not find hardware support for SSSE3 on this machine.")
|
|
118
|
+endif(NOT SSSE3_FOUND)
|
|
119
|
+
|
|
120
|
+if(NOT SSE4_1_FOUND)
|
|
121
|
+ MESSAGE(STATUS "Could not find hardware support for SSE4.1 on this machine.")
|
|
122
|
+endif(NOT SSE4_1_FOUND)
|
|
123
|
+
|
|
124
|
+mark_as_advanced(SSE_FOUND SSE2_FOUND SSE3_FOUND SSSE3_FOUND SSE4_1_FOUND)
|