# Print cause of rebuilt

**URL:** https://discourse.cmake.org/t/print-cause-of-rebuilt/9641
**Category:** Usage
**Created:** [December 15, 2023, 1:02pm UTC](https://discourse.cmake.org/t/print-cause-of-rebuilt/9641 "2023-12-15T13:02:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Martin\_Santa\_Maria](https://discourse.cmake.org/user_avatar/discourse.cmake.org/martin_santa_maria/32/3843_2.png) [@Martin\_Santa\_Maria](https://discourse.cmake.org/u/Martin_Santa_Maria)
#### Post date: [December 15, 2023, 1:02pm UTC](https://discourse.cmake.org/t/print-cause-of-rebuilt/9641/1 "2023-12-15T13:02:16Z")

</div>

Hello,

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.  
Regards,

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [December 15, 2023, 8:43pm UTC](https://discourse.cmake.org/t/print-cause-of-rebuilt/9641/2 "2023-12-15T20:43:00Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![neundorf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neundorf/32/2075_2.png) [@neundorf](https://discourse.cmake.org/u/neundorf)
#### Post date: [December 16, 2023, 11:14am UTC](https://discourse.cmake.org/t/print-cause-of-rebuilt/9641/3 "2023-12-16T11:14:45Z")

</div>

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

> [@Visual Studio: Some files not recompiled - how to debug ?](https://discourse.cmake.org/t/visual-studio-some-files-not-recompiled-how-to-debug/8200):
>
> Hi, in one of my projects it happens from time to time that when building with Visual Studio (not Code), I get linker errors, because some cpp files have not been recompiled. So it seems that after a header was edited, some cpp files were not recompiled, although they use that header indirectly. How are those dependencies handled in Visual Studio projects, where can I start looking ? Do you have suggestions how to debug this issue ? Thanks in advance

Maybe it works for you.
