<div dir="ltr"><div>Looking at the way these things work, it seems to me that the ideal solution to my situation, if it is possible, is to do a add_custom_command() for each source file, and then do a add_custom_target() that has all of the custom commands as PRE_BUILD events.</div><div><br></div><div>Is there a way to pass the list of files generated with the custom commands to the custom target?  As command line arguments would be just fine.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 7, 2015 at 1:37 PM, Alexander Neundorf <span dir="ltr"><<a href="mailto:a.neundorf-work@gmx.net" target="_blank">a.neundorf-work@gmx.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tuesday, April 07, 2015 13:22:30 you wrote:<br>
> > > > I have a custom executable that does some codegen to produce an<br>
> > > ><br>
> >> > > enumeration and a couple of tables.  I need this to be run against<br>
> >><br>
> >> each<br>
> >><br>
> >> > > source file before actual compilation.  It needs include directories<br>
> >><br>
> >> and<br>
> >><br>
> >> > > macro definitions from the build system.<br>
> >> > ><br>
> >> > > Is there a way to do this with a CMake build system?<br>
> >><br>
> >> add_custom_command<br>
> >><br>
> >> > > seems like it might work, but I need all runs of the custom<br>
> >><br>
> >> executable to<br>
> >><br>
> >> > > run before compilation begins.<br>
> >> ><br>
> >> > execute_process() might be what you want:<br>
> >> > <a href="http://www.cmake.org/cmake/help/v3.2/command/execute_process.html" target="_blank">http://www.cmake.org/cmake/help/v3.2/command/execute_process.html</a><br>
> >><br>
> >> Hmmm, probably add_custom_command() or add_custom_target() is what he<br>
> >> wants.<br>
> >> Why does it have to run before the compilation begins ?<br>
><br>
> The program will run once per source file, scan them, and generate a header<br>
> file that is necessary for compilation to succeed.<br>
<br>
</div></div>You could create a add_custom_target(foo); make your actual target depend on<br>
it, so it is finished before the actual compilation starts using<br>
add_dependencies().<br>
<br>
Alex<br>
<br>
</blockquote></div><br></div>