TL; DR

Have a try at setting SET(APPLE FALSE).


I've encountered a similar problem when cross-compiling a RISC-V project on my MacBook with macOS Sonoma. I found that CMake will set -arch arm64 by default, and there is an option controlling the argument to -arch called CMAKE_OSX_ARCHITECTURES. However, setting this argument to false does not help since CMake still applies a default value of arm64 which is the architecture of the build host.

I'm rather curious about why there's not much information about this question on the Internet; both on StackOverflow and GitHub are some questions/issues on this problem but no one gave a sharp and clear answer, at least none solved my issue.

So, I dived into the source code of CMake and found that if the target is set as Apple platforms, there will be a hardcoded appending to the compilation flags, which caused this problem. Finally, we can avoid this by setting APPLE variable to false, effectively simulating building on other platforms if you do not need to build a universal package which is almost always the case today.

Answer from abmfy on Stack Overflow
🌐
Arch Linux
archlinux.org › packages › extra › x86_64 › arm-none-eabi-gcc
Arch Linux - arm-none-eabi-gcc 14.2.0-2 (x86_64)
View the file list for arm-none-eabi-gcc · View the soname list for arm-none-eabi-gcc
🌐
Arch Linux
aur.archlinux.org › packages › gcc-arm-none-eabi-bin
AUR (en) - gcc-arm-none-eabi-bin - Arch Linux
# Original Maintainer: James Duley <jagduley gmail> # Previous Maintainer: 2bluesc <2bluesc gmail.com> # Maintainer: Vadzim Dambrouski <pftbest gmail.com> pkgname=gcc-arm-none-eabi-bin pkgver=10_2020_q4_major pkgrel=1 pkgdesc="GNU Tools ARM Embedded Processors (binary distribution, includes newlib, does NOT include GDB)" arch=('aarch64','x86_64') depends=('glibc') optdepends=( 'arm-none-eabi-gdb: GNU Debugger for ARM EABI' ) provides=('gcc-arm-none-eabi' 'arm-none-eabi-gcc' 'arm-none-eabi-binutils' 'arm-none-eabi-newlib' ) conflicts=('gcc-arm-none-eabi' 'arm-none-eabi-gcc' 'arm-none-eabi-binut
Discussions

arm none eabi gcc - unrecognized command-line option '-arch'; did you mean '-march='? - Stack Overflow
I'm trying to build a STM32 project on MacBook M1 with CMake and arm-none-eabi-gcc. These are my CMake codes: cmake_minimum_required(VERSION 3.0.0) project(Embedded VERSION 0.1.0) set(CMAKE_C_COMPI... More on stackoverflow.com
🌐 stackoverflow.com
arm-none-eabi-gcc-10.3.1: error: arm64
Hello Using you "brew install arm-none-eabi-gcc" command I just installed your toolchain. I am running a MacOS Monterey; with Apple M1 chip. Running cmake command I have this error : Run ... More on github.com
🌐 github.com
5
November 22, 2021
Missing libraries in arm-none-eabi-* ?
That's a bare metal target, I don't think it should have gnu/linux runtime libraries and your program should probably not link those, if you target it. What is your code supposed to run on? Maybe you need arm-linux-gnueabi[hf]-gcc from the AUR? More on reddit.com
🌐 r/archlinux
6
3
December 14, 2020
Arch Linux ARM • View topic - Failure trying to build arm-none-eabi-gcc (for qmk)
Ask questions about Arch Linux ARM. Please search before making a new topic. ... I'm trying to build `arm-none-eabi-gcc`, which is a dependency for `qmk`. So far I've built `arm-none-eabi-binutils` by simply changing `arch` to `aarm64`. Because of a circular dependency, I fetched ... More on archlinuxarm.org
🌐 archlinuxarm.org
March 22, 2022
🌐
Debian
packages.debian.org › trixie › amd64 › gcc-arm-none-eabi
Details of package gcc-arm-none-eabi in trixie
I Challenge Thee · AI scrapers break the web, to use this page you'll need JavaScript enabled
🌐
GitHub
github.com › ARMmbed › homebrew-formulae › issues › 32
arm-none-eabi-gcc-10.3.1: error: arm64 · Issue #32 · ARMmbed/homebrew-formulae
November 22, 2021 - Run Build Command(s):/usr/bin/make ... CMakeFiles/cmTC_972b1.dir/testCCompiler.c.o /opt/homebrew/bin/arm-none-eabi-gcc-10.3.1 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk -o CMakeFiles/cmTC_972b...
Author   jeanguerin
🌐
Homebrew
formulae.brew.sh › formula › arm-none-eabi-gcc
arm-none-eabi-gcc — Homebrew Formulae
brew install arm-none-eabi-gcc · GNU compiler collection for arm-none-eabi · https://gcc.gnu.org · License: GPL-3.0-or-later WITH GCC-exception-3.1 · Development: Pull requests · Formula JSON API: /api/formula/arm-none-eabi-gcc.json · Formula code: arm-none-eabi-gcc.rb on GitHub ·
🌐
Arch Linux ARM
archlinuxarm.org › forum › viewtopic.php
Arch Linux ARM • View topic - Failure trying to build arm-none-eabi-gcc (for qmk)
March 22, 2022 - Ask questions about Arch Linux ARM. Please search before making a new topic. ... I'm trying to build `arm-none-eabi-gcc`, which is a dependency for `qmk`. So far I've built `arm-none-eabi-binutils` by simply changing `arch` to `aarm64`. Because of a circular dependency, I fetched `arm-none-eabi-newlib` from upstream archlinux (since it's an `arch=(any)` package, it works fine).
Find elsewhere
🌐
Arch Linux
archlinux.org › packages › extra › any › arm-none-eabi-newlib
Arch Linux - arm-none-eabi-newlib 4.5.0.20241231-2 (any)
Arch Linux · Home · Packages · Forums · Wiki · GitLab · Security · AUR · Download · Source Files / View Changes · Bug Reports / Add New Bug · Search Wiki / Manual Pages · Security Issues · Flagged out-of-date on 2026-02-04 · Download From Mirror · arm-none-eabi-gcc (make) libopencm3 ·
🌐
Arch Linux
aur.archlinux.org › packages › arm-none-eabi-gcc53-linaro
AUR (en) - arm-none-eabi-gcc53-linaro - Arch Linux
May 29, 2016 - http://releases.linaro.org/components/toolchain/gcc-linaro/5.3-2016.02/gcc-linaro-5.3-2016.02.tar.xz · Hi WTX, can you contact me? I'd like to talk about removing a few of either my or your repositories, in order to clean up the AUR a bit. I'm a bit more open for suggestions nwo than I was 2 years ago ;-) @jhalfmoon: Ok, I've made fork package named: "arm-none-eabi-gcc53-linaro-alternative".
🌐
GitHub
github.com › qmk › qmk_firmware › issues › 8809
[Bug] arm-none-eabi-gcc error on Arch Linux · Issue #8809 · qmk/qmk_firmware
April 15, 2020 - [Bug] arm-none-eabi-gcc error on Arch Linux#8809 · #9044 · Copy link · Labels · bughelp wanted · ghost · opened · on Apr 15, 2020 · No description provided. Reactions are currently unavailable · No one assigned · bughelp wanted · No type · No projects ·
Author   ghost
🌐
Arch Linux
archlinux.org › packages › extra › x86_64 › arm-none-eabi-gcc › files
Arch Linux - arm-none-eabi-gcc 14.2.0-2 (x86_64) - File List
usr/arm-none-eabi/include/c++/14.2.0/arm-none-eabi/thumb/v8-m.main+dp/softfp/ext/opt_random.h · usr/arm-none-eabi/include/c++/14.2.0/arm-none-eabi/thumb/v8-m.main+fp/
🌐
Arch Linux Forums
bbs.archlinux.org › viewtopic.php
[SOLVED] arm-none-eabi header pakage missing / AUR Issues, Discussion & PKGBUILD Requests / Arch Linux Forums
Remember that arm-none-eabi-* is bare metal toolchain. Bare metal here means that your end program is going to run on a hardware without any operating system. That how firmware for microcontrollers work for example. Now in your example you use stdio.h header that is part of libc. You need a libc for your bare metal app, and Arch provides *-newlib for this.
🌐
CMake Discourse
discourse.cmake.org › code
How to remove -arch flag from arm-none-eabi-gcc in macos builds - Code - CMake Discourse
January 27, 2023 - 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.
🌐
GitHub
github.com › conan-io › conan › issues › 10053
[question] Cross compiling embedded with gcc-arm-none-eabi · Issue #10053 · conan-io/conan
# Only for cross building, 'os_build/arch_build' is the system that runs Conan os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS, AIX] arch_build: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7] # Only for building cross compilation tools, 'os_target/arch_target' is the system for # which the tools generate code os_target: [Windows, Linux, Macos, Android, iOS, watchOS, tvOS, FreeBSD, SunOS, AIX, Ardu
Author   ghost
🌐
Arm Learning
learn.arm.com › install-guides › gcc › arm-gnu
Arm GNU Toolchain | Arm Learning Paths
sudo installer -pkg arm-gnu-toolchain-<version>-<host-arch>-<TRIPLE>.pkg -target / Use a text editor to add the bin directory as a new line in /etc/paths. For example the path could be: /Applications/ArmGNUToolchain/15.2.rel1/arm-none-eabi/bin
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 16420793770258-arm-none-eabi-gcc-test-project-failed
arm-none-eabi-gcc test project failed – IDEs Support (IntelliJ Platform) | JetBrains
January 16, 2024 - Change Dir: '/private/var/fold...ents/bin/ninja/mac/aarch64/ninja -v cmTC_e921e [1/2] /opt/homebrew/bin/arm-none-eabi-gcc -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk -fdiagnostics-color=always ...
🌐
Debian
packages.debian.org › bookworm › gcc-arm-none-eabi
Debian -- Details of package gcc-arm-none-eabi in bookworm
libstdc++-arm-none-eabi-picolibc ... gcc-riscv64-unknown-elf · libnewlib-arm-none-eabi · gcc-xtensa-lx106 · Bare metal C and C++ compiler for embedded ARM chips using Cortex-M, and Cortex-R processors....