<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body><div>On Thu, 2019-03-28 at 15:26 -0400, Norton Allen wrote:</div><blockquote type="cite">
<div class="moz-cite-prefix">On 3/28/2019 3:11 PM, Kyle Edwards
wrote:<br>
</div>
<blockquote type="cite" cite="mid:1553800309.3145.3.camel@kitware.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div>On Thu, 2019-03-28 at 14:58 -0400, Norton Allen wrote:</div>
<blockquote type="cite">
<blockquote> </blockquote>
<p>because mygeneratedfile is not a 'target', and I can't make
it into a target with add_custom_target() because that's
talking about something else entirely (commands that will be
run unconditionally, not based on dependencies)</p>
</blockquote>
<div><br>
</div>
<div>What exactly do you mean by "based on dependencies"? Do you
mean that this file has dependencies on something else, or that
something else has dependencies on it?</div>
</blockquote>
<p>I mean this file depends on some source files--if the source
files change, I want to rerun the generation step.<br></p></blockquote><div><br></div><div>Using the DEPENDS argument of add_custom_command() will do this. However, add_custom_command() on its own isn't enough to ensure that the file is generated before installation. You need to pair add_custom_command() with add_custom_target(). Example:</div><div><br></div><div><span style="color: rgb(0, 0, 0);">add_custom_command(</span><br style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);"> OUTPUT mygeneratedfile</span><br style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);"> COMMAND mytool -o mygeneratedfile</span><br style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);"> DEPENDS mysourcefile</span><br style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 0);">)</span></div><div><span style="color: rgb(0, 0, 0);">add_custom_target(mygeneratedtarget</span></div><div><span style="color: rgb(0, 0, 0);"> DEPENDS mygeneratedfile</span></div><div><span style="color: rgb(0, 0, 0);">)</span></div><div><span style="color: rgb(0, 0, 0);"><br></span></div><div><span style="color: rgb(0, 0, 0);">This is different from:</span></div><div><span style="color: rgb(0, 0, 0);"><br></span></div><div><span style="color: rgb(0, 0, 0);">add_custom_target(mygeneratedtarget</span></div><div><span style="color: rgb(0, 0, 0);"> COMMAND mytool -o mygeneratedfile</span></div><div><span style="color: rgb(0, 0, 0);"> BYPRODUCTS mygeneratedfile</span></div><div><span style="color: rgb(0, 0, 0);"> DEPENDS mysourcefile</span></div><div><span style="color: rgb(0, 0, 0);">)</span></div><div><span style="color: rgb(0, 0, 0);"><br></span></div><div><span style="color: rgb(0, 0, 0);">because it will only run mytool when it needs to (when mysourcefile has changed).</span></div><div><span style="color: rgb(0, 0, 0);"><br></span></div><div><span style="color: rgb(0, 0, 0);">Kyle</span></div></body></html>