Use CMAKE_SYSTEM_PROCESSOR to check for SIMD support options (#3484)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2021-07-02 15:23:58 +02:00 committed by GitHub
parent 4b630a8813
commit 4333b2cea3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -140,16 +140,12 @@ if(COMPILER_SUPPORTS_MARCH_NATIVE)
set(MARCH_NATIVE_OPT ON)
endif()
if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64.*|AARCH64.*")
set(AARCH64 TRUE)
endif()
message("CMAKE_SYSTEM_PROCESSOR=<${CMAKE_SYSTEM_PROCESSOR}>")
if(AARCH64)
# Flags for SIMD support
set(HAVE_NEON FALSE)
add_definitions("-DHAVE_NEON")
set(HAVE_NEON TRUE)
else()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86|AMD64")
CHECK_CXX_COMPILER_FLAG("-mavx" HAVE_AVX)
if(HAVE_AVX)
@ -175,15 +171,6 @@ if(HAVE_SSE4_1)
add_definitions("-DHAVE_SSE4_1")
endif()
if(NOT APPLE)
# NEON support relies on getauxval, which is not available on OSX, only on Linux and Android
CHECK_CXX_COMPILER_FLAG("-mfpu=neon" HAVE_NEON)
if(HAVE_NEON)
set(NEON_COMPILE_FLAGS "-mfpu=neon")
add_definitions("-DHAVE_NEON")
endif()
endif(NOT APPLE)
if(MSVC)
if(NOT HAVE_AVX)
set(AVX_COMPILE_FLAGS "/arch:AVX")
@ -217,7 +204,30 @@ if(MSVC)
endif(CLANG)
endif(MSVC)
endif(AARCH64)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64.*|AARCH64.*")
set(HAVE_AVX FALSE)
set(HAVE_AVX2 FALSE)
set(HAVE_FMA FALSE)
set(HAVE_SSE4_1 FALSE)
add_definitions("-DHAVE_NEON")
set(HAVE_NEON TRUE)
else()
set(HAVE_AVX FALSE)
set(HAVE_AVX2 FALSE)
set(HAVE_FMA FALSE)
set(HAVE_SSE4_1 FALSE)
CHECK_CXX_COMPILER_FLAG("-mfpu=neon" HAVE_NEON)
if(HAVE_NEON)
set(NEON_COMPILE_FLAGS "-mfpu=neon")
add_definitions("-DHAVE_NEON")
endif()
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86|AMD64")
# auto optimize - used only for information about available vectors
include(OptimizeForArchitecture)