1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-04-28 13:43:20 +00:00

Improved processor/feature detection when building with MSVC

This commit is contained in:
Carles Fernandez 2016-02-07 10:56:21 +01:00
parent ad05245414
commit 794d141e84

View File

@ -87,7 +87,7 @@ endif(NOT DEFINED _XOPEN_SOURCE)
######################################################################## ########################################################################
# detect x86 flavor of CPU # detect x86 flavor of CPU
######################################################################## ########################################################################
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i.86|x86|x86_64|amd64)$") if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^(i.86|x86|x86_64|amd64|AMD64)$")
message(STATUS "x86* CPU detected") message(STATUS "x86* CPU detected")
set(CPU_IS_x86 TRUE) set(CPU_IS_x86 TRUE)
endif() endif()
@ -106,9 +106,13 @@ macro(check_arch arch_name)
set(flags ${ARGN}) set(flags ${ARGN})
set(have_${arch_name} TRUE) set(have_${arch_name} TRUE)
foreach(flag ${flags}) foreach(flag ${flags})
if ( (${COMPILER_NAME} STREQUAL "MSVC") AND (${flag} STREQUAL "/arch:SSE2" OR ${flag} STREQUAL "/arch:SSE" ))
# SSE/SSE2 is supported in MSVC since VS 2005 but flag not available when compiling 64-bit so do not check
else()
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
set(have_flag have${flag}) set(have_flag have${flag})
execute_process( #make the have_flag have nice alphanum chars (just for looks/not necessary) #make the have_flag have nice alphanum chars (just for looks/not necessary)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import re; print(re.sub('\\W', '_', '${have_flag}'))" COMMAND ${PYTHON_EXECUTABLE} -c "import re; print(re.sub('\\W', '_', '${have_flag}'))"
OUTPUT_VARIABLE have_flag OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE have_flag OUTPUT_STRIP_TRAILING_WHITESPACE
) )
@ -120,6 +124,7 @@ macro(check_arch arch_name)
if (NOT ${have_flag}) if (NOT ${have_flag})
set(have_${arch_name} FALSE) set(have_${arch_name} FALSE)
endif() endif()
endif()
endforeach() endforeach()
if (have_${arch_name}) if (have_${arch_name})
list(APPEND available_archs ${arch_name}) list(APPEND available_archs ${arch_name})