Open Source Tomb Raider Engine
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

FindSSE.cmake 5.0KB

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