title: Rebuild only if the source was modified by a previous command
body: <p>I have a python script which extracts information from a C++ source file and writes it to a header file. Whenever this generated header changes (which happens rarely), I want to re-compile it (via the GCC precompiled header feature).</p>
  
  <p>Obviously, the command invoking the script depends on the source file, and the recompiling command depends on the header file generated by the script.</p>
  
  <pre><code>add_custom_command(OUTPUT "file.pch.h" COMMAND &lt;script&gt; DEPENDS "file.cpp")
  add_custom_command(OUTPUT "file.pch.h.gch" COMMAND &lt;compile&gt; DEPENDS "file.pch.h")
  </code></pre>
  
  <p>But now <code>file.pch.h.gch</code> depends on <code>file.cpp</code> and is recompiled whenever it changes. How can I avoid this?</p>