Skip to content

macOS: Suppress default '-arch arm64' with CMAKE_<LANG>_COMPILER_TARGET

Brad King requested to merge brad.king/cmake:apple-archs into master

Since !5291 (merged) we add -arch arm64 by default on Apple Silicon hosts if CMAKE_OSX_ARCHITECTURES is not set. This is necessary to prevent the toolchain from selecting its own default architecture based on that of the build tool (e.g., x86_64).

If CMAKE_<LANG>_COMPILER_TARGET is set, its -target flag tells the compiler what architecture to use, so do not add -arch arm64.

Fixes: #24599 (closed)

Merge request reports