[cmake] Enable mcpu=native for all Arm processors (#6156)

This commit is contained in:
Stefan Wunsch 2021-03-06 12:37:44 +01:00 committed by GitHub
parent df9f33e44e
commit 47b1804034
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 7 deletions

View File

@ -7,13 +7,8 @@ set(PROC_TARGET_1_FLAGS "-mtune=generic" CACHE STRING "Processor-1 flags")
# This second choice should be used for your own build only
set(PROC_TARGET_2_LABEL native CACHE STRING "Processor-2 label - use it for your own build")
# Get the architecture on an Apple system (x86 or arm64)
if(APPLE)
execute_process(COMMAND uname -m OUTPUT_VARIABLE APPLE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# On Apple's M1 processor and with Apple's clang compiler, the native flag is different
if(CMAKE_CXX_COMPILER_ID STREQUAL AppleClang AND APPLE_ARCHITECTURE STREQUAL arm64)
# The flag is different on x86 and Arm based processors
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL arm64)
set(PROC_TARGET_2_FLAGS "-mcpu=native" CACHE STRING "Processor-2 flags")
else()
set(PROC_TARGET_2_FLAGS "-march=native" CACHE STRING "Processor-2 flags")