PCH generation process breaks programs that rely on compile_commands.json
When a precompiled header is used, CMake creates 2 files for it: cmake_pch.cxx and cmake_pch.hxx. When compiler is run, it creates .pch file by including .hxx file from command line and compiling empty .cxx file. But this behavior breaks programs that use compile_commands.json for preprocessing files from build. When Clang compiler is used, the file included with -include-pch
flag is preprocessed by extracting original filename from .pch - in this case, .cxx file will be incorrectly used. All include information from pch generation step is lost. Preprocessed file is corrupted because of that.