Closed SSE4 closed 7 years ago
cc1plus: error: unrecognized argument in option '-march=native'
cc1plus: note: valid arguments to '-march=' are: armv2 [...] native
I am puzzled. It says that it doesn't recognize the argument but that it is still a valid argument?
We could use:
include(CheckCXXCompilerFlag)
macro(range_v3_append_flag testname flag)
check_cxx_compiler_flag(${flag} ${testname})
if (${testname})
add_compile_options(${flag})
endif()
endmacro()
range_v3_append_flag(RANGE_V3_HAS_MARCH_NATIVE "-march=native")
range_v3_append_flag(RANGE_V3_HAS_MTUNE_NATIVE "-mtune=native")
to detect whether the compiler supports a particular flag, and then use it only if supported (i.e. if compiling a dummy file with the flag doesn't produce a compilation error).
some tool-chains (e.g. Android NDK) might not support -march=native or -mtune=native compiler flags. for example, gcc throws the following error:
and clang: