# Set native march/mcpu
if(WITH_NATIVE_INSTRUCTIONS)
if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
- if(BASEARCH_PPC_FOUND)
- set(NATIVEFLAG "-mcpu=native")
- else()
+ check_c_compiler_flag(-march=native HAVE_MARCH_NATIVE)
+ if(HAVE_MARCH_NATIVE)
set(NATIVEFLAG "-march=native")
+ else()
+ check_c_compiler_flag(-mcpu=native HAVE_MCPU_NATIVE)
+ if(HAVE_MCPU_NATIVE)
+ set(NATIVEFLAG "-mcpu=native")
+ endif()
endif()
+ # Fall through
+ endif()
+ if(NATIVEFLAG)
# Apply flag to all source files and compilation checks
add_compile_options(${NATIVEFLAG})
else()