[cmake] Enable native compilation on Apple M1 (#6152)
This commit is contained in:
parent
84751ad26f
commit
02b86239db
@ -6,7 +6,18 @@ set(PROC_TARGET_1_FLAGS "-mtune=generic" CACHE STRING "Processor-1 flags")
|
|||||||
|
|
||||||
# This second choice should be used for your own build only
|
# 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")
|
set(PROC_TARGET_2_LABEL native CACHE STRING "Processor-2 label - use it for your own build")
|
||||||
set(PROC_TARGET_2_FLAGS "-march=native" CACHE STRING "Processor-2 flags")
|
|
||||||
|
# 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)
|
||||||
|
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")
|
||||||
|
endif()
|
||||||
|
|
||||||
# The later choices is intended to be used if you want to provide specific builds, but it should match your own processor
|
# The later choices is intended to be used if you want to provide specific builds, but it should match your own processor
|
||||||
# You can cross compile but you have to know what you're doing, this mechanism has not been designed for that
|
# You can cross compile but you have to know what you're doing, this mechanism has not been designed for that
|
||||||
|
Loading…
x
Reference in New Issue
Block a user