Print cause of rebuilt


I have a fairly complicated project with lots of dependencies and custom targets and commands. I’m getting some rebuilds, and until now they have all been proven to be right after analysis; but it is never easy to confirm it, and we loose quite a time on checking them.
Is there a way to ask cmake to print the cause of rebuild? something like “rebuilding because dependency changed”?
I have checked the debug prints, but they are not that useful.

This is down to the build tool. ninja -d explain and make -d work (but are not necessarily trivial to extract information from). No idea if MSBuild or Xcode support such diagnostics or not.

msbuild has -v:diag , this prints a lot, but it didn’r print what I wanted to see:

Maybe it works for you.