How to remove -arch flag from arm-none-eabi-gcc in macos builds

I am cross compiling using arm-none-eabi-gcc on MacOS (M1) with rosetta x86. It does not make sense to have -arch x86_64b compilation flag as it gives error. v12 of arm-none-eabi-gcc (latest from brew) does not support -arch flag. cmake should not add this flag for eabi.

How do you remove this flag?

I get this error:
arm-none-eabi-gcc: error: unrecognized command-line option ‘-arch’; did you mean ‘-march=’?

(I see that pico-sdk compiles somehow remove this flag. There has to be some settable parameter. I looked but nothing obvious stood out.)

Where the flag comes from would be of interest… Does cmake --trace-expand show anything doing this? Might be necessary on an initial configure.

Solved. setting set(CMAKE_SYSTEM_NAME Linux) and set(CMAKE_SYSTEM_PROCESSOR ARM) will cause cmake to not look into MacOS toolchain through -arch flag.

On my mac, cmake still add -arch prarameter if I add the above 2 set().

Same problem on my M1 mac. Adding the two lines did not solve the problem.