Commands exported in compile_commands.json differ from actual commands used
While working on a MR for #24017 (closed), I was comparing the commands generated in compile_commands.json
when CMAKE_EXPORT_COMPILE_COMMANDS
is set to true. For a trivial file in the test suite, I noticed that on macOS the commands in compile_commands.json
were missing the -MD
, -MT
and -MF
arguments (they were present in the real compiler command). This seems unlikely to be deliberate, since it would open up opportunities for an IDE to compile a file using commands from compile_commands.json
, but the depfiles wouldn't be generated/updated. A later build would then be using stale depfiles. This seems like a bug, but I'll defer to someone more familiar with the depfile generation logic for a more informed opinion.