Commit 680b68e2 authored by steinbac's avatar steinbac

added minimal hardware name and cache size detection during build

parent c71a00a8
# Check if SSE instructions are available on the machine where
# the project is compiled.
##extract a single line that contains the given pattern (starting from that patter)
function(extract_line LINESTART_PATTERN MULTILINE_STRING OUTPUT_VARIABLE)
STRING(FIND ${MULTILINE_STRING} "${PATTERN}" MATCH_OFFSET)
STRING(SUBSTRING ${MATCH_OFFSET} 0 ${MATCH_OFFSET} MULTILINE_NO_START)
STRING(FIND ${MULTILINE_NO_START} "\n" MULTILINE_RETURN_OFFSET)
STRING(SUBSTRING ${MULTILINE_NO_START} 0 ${MULTILINE_RETURN_OFFSET} MATCHING_LINE)
set(OUTPUT_VARIABLE ${MATCHING_LINE} PARENT_SCOPE)
endfunction(extract_line)
##extract system information from wmic.exe on Windows
function(wmic_get ATTRIBUTENAME RESULTVALUE)
EXEC_PROGRAM("wmic.exe" ARGS "cpu get ${ATTRIBUTENAME}" OUTPUT_VARIABLE WMIC_OUTPUT)
string(REGEX REPLACE " [ ]+" ";" WMIC_OUTPUT_CLEANED ${WMIC_OUTPUT})
set(WMIC_OUTPUT_LIST "${WMIC_OUTPUT_CLEANED};")
list(GET WMIC_OUTPUT_LIST 1 VALUEOFINTEREST)
string(STRIP "${VALUEOFINTEREST}" VALUEOFINTEREST)
set(${RESULTVALUE} ${VALUEOFINTEREST} PARENT_SCOPE)
message(STATUS "[wmic_get] RESULT = ${VALUEOFINTEREST}")
endfunction(wmic_get)
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
EXEC_PROGRAM(cat ARGS "/proc/cpuinfo" OUTPUT_VARIABLE CPUINFO)
......@@ -203,42 +225,61 @@ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
endif()
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Windows")
# TODO
set(SSE2_FOUND true CACHE BOOL "SSE2 available on host")
set(SSE3_FOUND false CACHE BOOL "SSE3 available on host")
set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host")
set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host")
ELSE(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(SSE2_FOUND true CACHE BOOL "SSE2 available on host")
wmic_get("Name" MODEL_NAME)
string(STRIP ${MODEL_NAME} MODEL_NAME)
set(CPU_MODEL_NAME "${MODEL_NAME}" CACHE STRING "cpu model name")
wmic_get("Manufacturer" MODEL_VENDOR)
set(CPU_VENDOR "${MODEL_VENDOR}" CACHE STRING "cpu model vendor")
wmic_get("L2CacheSize" L2_CACHE_SIZE)
set(CPU_L2_SIZE_KB "${L2_CACHE_SIZE}" CACHE STRING "cpu L2 cache size in kB")
set(SSE_FOUND false CACHE BOOL "SSE available on host")
set(SSE2_FOUND false CACHE BOOL "SSE2 available on host")
set(SSE3_FOUND false CACHE BOOL "SSE3 available on host")
set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host")
set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host")
set(SSE4_2_FOUND false CACHE BOOL "SSE4.2 available on host")
set(AVX_FOUND false CACHE BOOL "AVX available on host")
set(AVX2_FOUND false CACHE BOOL "AVX2 available on host")
#ELSE(CMAKE_SYSTEM_NAME MATCHES "Linux")
# set(SSE2_FOUND true CACHE BOOL "SSE2 available on host")
# set(SSE3_FOUND false CACHE BOOL "SSE3 available on host")
# set(SSSE3_FOUND false CACHE BOOL "SSSE3 available on host")
# set(SSE4_1_FOUND false CACHE BOOL "SSE4.1 available on host")
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
if(NOT SSE_FOUND)
MESSAGE(STATUS "Could not find hardware support for SSE on this machine.")
endif(NOT SSE_FOUND)
if(NOT SSE2_FOUND)
MESSAGE(STATUS "Could not find hardware support for SSE2 on this machine.")
endif(NOT SSE2_FOUND)
if(NOT SSE3_FOUND)
MESSAGE(STATUS "Could not find hardware support for SSE3 on this machine.")
endif(NOT SSE3_FOUND)
if(NOT SSSE3_FOUND)
MESSAGE(STATUS "Could not find hardware support for SSSE3 on this machine.")
endif(NOT SSSE3_FOUND)
if(NOT SSE4_1_FOUND)
MESSAGE(STATUS "Could not find hardware support for SSE4.1 on this machine.")
endif(NOT SSE4_1_FOUND)
if(NOT SSE4_2_FOUND)
MESSAGE(STATUS "Could not find hardware support for SSE4.2 on this machine.")
endif(NOT SSE4_2_FOUND)
if(NOT AVX_FOUND)
MESSAGE(STATUS "Could not find hardware support for AVX on this machine.")
endif(NOT AVX_FOUND)
if(NOT AVX2_FOUND)
MESSAGE(STATUS "Could not find hardware support for AVX2 on this machine.")
endif(NOT AVX2_FOUND)
message(STATUS "found hardware: ${CPU_VENDOR} ${CPU_MODEL_NAME}")
set(FOUND_FEATURES)
if(SSE_FOUND)
list(APPEND FOUND_FEATURES "sse")
endif(SSE_FOUND)
if(SSE2_FOUND)
list(APPEND FOUND_FEATURES "sse2")
endif(SSE2_FOUND)
if( SSE3_FOUND)
list(APPEND FOUND_FEATURES "sse3")
endif( SSE3_FOUND)
if( SSSE3_FOUND)
list(APPEND FOUND_FEATURES "ssse3")
endif( SSSE3_FOUND)
if( SSE4_1_FOUND)
list(APPEND FOUND_FEATURES "sse4.1")
endif( SSE4_1_FOUND)
if( SSE4_2_FOUND)
list(APPEND FOUND_FEATURES "sse4.2")
endif( SSE4_2_FOUND)
if( AVX_FOUND)
list(APPEND FOUND_FEATURES "avx")
endif( AVX_FOUND)
if( AVX2_FOUND)
list(APPEND FOUND_FEATURES "avx2")
endif( AVX2_FOUND)
message(STATUS "found hardware features: ${FOUND_FEATURES}")
mark_as_advanced(SSE_FOUND SSE2_FOUND SSE3_FOUND SSSE3_FOUND SSE4_1_FOUND SSE4_2_FOUND AVX_FOUND AVX2_FOUND CPU_VENDOR CPU_MODEL_NAME CPU_L2_SIZE_KB)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment