title: CMake - tracing and debugging targets dependencies
body: <p>I have a rather complicated <code>CMakeLists.txt</code> file with multiple <code>add_subdirectory</code>'s, <code>add_custom_command</code>'s, and <code>add_custom_target</code>'s. I don't modify any source files. However some binary targets are always rebuilt and it takes valuable time. I have to debug this issue, or write new a <code>CMakeLists.txt</code> file from scratch.</p>
  
  <p>Is there a way to get from CMake information about why it rebuilds a particular target at build time?</p>
  
  <p>For example, GNU Make has the <code>--debug</code> command line option:</p>
  
  <pre><code>Considering target file 'foo.exe'.
  Prerequisite 'bar.cpp' is newer than target 'foo.exe'.
  Must remake target 'foo.exe'
  </code></pre>
  
  <p>Maybe CMake has something similar? There are <code>--debug</code> and <code>--trace</code> options, but they seem to be handled at configure time and are not able to say something at build time.</p>
  
  <p>CMake has the <code>--graphviz</code> option for that, but it shows only binary targets. No interface, alias, and added dependencies support. There are appropriate tickets in the official tracker:</p>
  
  <ul>
  <li><em><a href="https://gitlab.kitware.com/cmake/cmake/issues/15638" rel="nofollow noreferrer">Interface libraries and --graphviz</a></em></li>
  <li><em><a href="https://gitlab.kitware.com/cmake/cmake/issues/15636" rel="nofollow noreferrer">Alias libraries and --graphviz</a></em></li>
  <li><em><a href="https://gitlab.kitware.com/cmake/cmake/issues/13809" rel="nofollow noreferrer">'add_dependencies' and --graphviz</a></em></li>
  </ul>