GCC (and I assume Clang) on macOS have the -arch option as opposed to the -march option. The difference is that on macOS you might want to compile a universal binary and -arch takes more than one architecture so you end up with a binary that can be used universally.
All good and kinda irrelevant to my project. However, according to a GitLab issue, CMake is trying to figure this out on an M1 by checking if the architecture you’re compiling to is arm64. Regardless of any other options.
The issue is that the Raspberry Pi 3 and 4 are also arm64. So CMake thinks that with aarch64-elf-gcc, I’m able to create universal binaries.
But you can’t. MacOS isn’t even using elf so the compiler is obviously not implementing this option.
How do I tell CMake to stop assuming that just because I’m targeting arm64, I’ll be using a macOS specific compiler?
Otherwise, the test compilation on configuration is failing because it’s trying to use -arch. You get this error:
aarch64-elf-gcc: error: unrecognized command-line option ‘-arch’; did you mean ‘-march=’?