macOS/GCC: Incorrect flag on arm64 when precompiled headers are used
cmake version 3.28.0 g++-13 (Homebrew GCC 13.2.0) 13.2.0
I have a test app that reproduces the issue but you need GCC (not sure if version is important) installed on your arm64 Mac computer. (Test app here https://github.com/kuikka/include_problem)
cmake --preset gcc
After configuring, trying to build fails:
% cmake --build out/build/gcc
[1/2] Building CXX object CMakeFiles/app.dir/main.cpp.o
FAILED: CMakeFiles/app.dir/main.cpp.o
/opt/homebrew/bin/g++-13 -I/Users/kuikka/dev/include_problem/. -g -std=gnu++20 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk -Winvalid-pch -Xarch_arm64 -include/Users/kuikka/dev/include_problem/out/build/gcc/CMakeFiles/app.dir/cmake_pch_arm64.hxx -MD -MT CMakeFiles/app.dir/main.cpp.o -MF CMakeFiles/app.dir/main.cpp.o.d -o CMakeFiles/app.dir/main.cpp.o -c /Users/kuikka/dev/include_problem/main.cpp
g++-13: error: unrecognized command-line option '-Xarch_arm64'
ninja: build stopped: subcommand failed.
The failing option -Xarch_arm64
is specific to clang and fails on gcc.
If I comment out the "target_precompile_headers" in CMakeLists.txt and reconfigure, the build succeeds.
Edited by Juha Kuikka