Bladeren bron

Added SSE detection

Thomas Buck 10 jaren geleden
bovenliggende
commit
4f383dbc60
4 gewijzigde bestanden met toevoegingen van 171 en 6 verwijderingen
  1. 16
    5
      README.md
  2. 124
    0
      cmake/FindSSE.cmake
  3. 30
    0
      src/CMakeLists.txt
  4. 1
    1
      src/OpenRaider.cpp

+ 16
- 5
README.md Bestand weergeven

@@ -218,14 +218,25 @@ The included sample WAV file is made from the [Falling Mate ringtone](http://bre
218 218
 
219 219
 The included Unit Test Framework [greatest](https://github.com/silentbicycle/greatest/) by Scott Vokes is licensed under the [ISC License](http://www.isc.org/downloads/software-support-policy/isc-license/).
220 220
 
221
-The included cmake scripts [FindALUT](https://github.com/rpavlik/cmake-modules/blob/master/FindALUT.cmake), [FindSDL2](https://github.com/dhewm/dhewm3/blob/master/neo/sys/cmake/FindSDL2.cmake) and [FindSDL2TTF](https://github.com/Deraen/ohj2710/blob/master/cmake_modules/FindSDL2TTF.cmake) are released under the Boost Software License (for FindALUT) and under the BSD License for the other two. Authors: Ryan Pavlik, Iowa State University, Eric Wing and Kitware Inc.
221
+There are some included cmake scripts:
222
+
223
+* [FindALUT](https://github.com/rpavlik/cmake-modules/blob/master/FindALUT.cmake)
224
+* [FindSDL2](https://github.com/dhewm/dhewm3/blob/master/neo/sys/cmake/FindSDL2.cmake)
225
+* [FindSDL2TTF](https://github.com/Deraen/ohj2710/blob/master/cmake_modules/FindSDL2TTF.cmake)
226
+* [FindSSE](https://gitorious.org/vc/vc/source/a1d8b9fc31060d870386613cc72319546c850b87:cmake/FindSSE.cmake)
227
+
228
+See the respective files in `cmake` for their licensing.
229
+
230
+* Copyright 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>, Iowa State University, Distributed under the Boost Software License.
231
+* Copyright 2003-2009 Kitware, Inc.
232
+* Eric Wing
222 233
 
223 234
 OpenRaider is based on code, specs, and alogrithms from:
224 235
 
225
-+ GooseEgg/Freyja 3d Modelers by Mongoose
226
-+ TR Rosetta Stone spec sheet by Anonymous
227
-+ TRView 1.0.0 by Yuri Zhivago, with patches by Mongoose
236
+* GooseEgg/Freyja 3d Modelers by Mongoose
237
+* TR Rosetta Stone spec sheet by Anonymous
238
+* TRView 1.0.0 by Yuri Zhivago, with patches by Mongoose
228 239
 
229 240
 All code should be GPLed, unless otherwise noted.
230 241
 
231
-2013, 2014 improvements & clean-up by xythobuz.
242
+2013, 2014 improvements, clean-up by xythobuz.

+ 124
- 0
cmake/FindSSE.cmake Bestand weergeven

@@ -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)

+ 30
- 0
src/CMakeLists.txt Bestand weergeven

@@ -47,6 +47,36 @@ endif (APPLE)
47 47
 
48 48
 #################################################################
49 49
 
50
+# Check for SSE, enable if available
51
+include (../cmake/FindSSE.cmake)
52
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
53
+    if (SSE_FOUND)
54
+        set (SSE_FOUND_MSG "${SSE_FOUND_MSG} SSE")
55
+        set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -msse")
56
+    endif (SSE_FOUND)
57
+    if (SSE2_FOUND)
58
+        set (SSE_FOUND_MSG "${SSE_FOUND_MSG} SSE2")
59
+        set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -msse2")
60
+    endif (SSE2_FOUND)
61
+    if (SSE3_FOUND)
62
+        set (SSE_FOUND_MSG "${SSE_FOUND_MSG} SSE3")
63
+        set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -msse3")
64
+    endif (SSE3_FOUND)
65
+    if (SSSE3_FOUND)
66
+        set (SSE_FOUND_MSG "${SSE_FOUND_MSG} SSSE3")
67
+        set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -mssse3")
68
+    endif (SSSE3_FOUND)
69
+    if (SSE4_1_FOUND)
70
+        set (SSE_FOUND_MSG "${SSE_FOUND_MSG} SSE4.1")
71
+        set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -msse4.1")
72
+    endif (SSE4_1_FOUND)
73
+
74
+    # Display message if something is enabled
75
+    if (NOT "${SSE_FOUND_MSG}" STREQUAL "")
76
+        message ("Enabled${SSE_FOUND_MSG}...")
77
+    endif (NOT "${SSE_FOUND_MSG}" STREQUAL "")
78
+endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
79
+
50 80
 # Apply Flags
51 81
 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenRaider_CXX_FLAGS}")
52 82
 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OpenRaider_CXX_FLAGS} ${OpenRaider_CXX_FLAGS_DEBUG}")

+ 1
- 1
src/OpenRaider.cpp Bestand weergeven

@@ -63,7 +63,7 @@ void killOpenRaiderSingleton() {
63 63
     printf("Build date: %s @ %s\n", __DATE__, __TIME__);
64 64
     printf("Build host: %s\n", BUILD_HOST);
65 65
     printf("Web site  : http://github.com/xythobuz/OpenRaider\n");
66
-    printf("Contact   : xythobuz@xythobuz.de");
66
+    printf("Contact   : xythobuz@xythobuz.de\n");
67 67
 }
68 68
 
69 69
 

Laden…
Annuleren
Opslaan