For an AUTOMOC'ed target foo, when depfiles are used, there are the following dependencies:
foo_autogen -> foo_autogen/timestamp foo_autogen/mocs_compilation.cpp -> foo_autogen/timestamp
The first is used to trigger AUTOGEN. The second erroneously triggers a recompilation of mocs_compilation.cpp when any source file of target foo is touched.
Remove the latter dependency and replace it with an order-only dependency from foo_autogen/mocs_compilation.cpp to foo_autogen_timestamp_deps.
That is achieved by making mocs_compilation.cpp a byproduct of the timestamp file.
Fixes: #22338 (closed)