PCH: Fails with custom '-include something.h' source file flag
It appears that this is specific for Ninja generator on M1 Macs when targeting ARM architecture (and using target_precompile_headers
).
Namely, on Intel Macs, CMake 3.19.5 generates the following flags:
-Winvalid-pch -Xclang -include-pch -Xclang /path/to/build/dir/CMakeFiles/Target.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /path/to/build/dir/CMakeFiles/NeuralNetwork.dir/cmake_pch.hxx
while on ARM Macs, the following flags are generated:
-Winvalid-pch -Xarch_arm64 -include/path/to/build/dir/CMakeFiles/Target.dir/cmake_pch_arm64.hxx
Now, when compiling a source file that already has a custom -include something.hpp
added to its COMPILE_OPTIONS
, the PCH include is not the first include, which causes mentioned compile warning.
If you treat all warnings as errors (as we do), this causes build failure.
We are using cmake 3.19.5 universal binary.