[CMake] Running custom executable

Daniel Dilts diltsman at gmail.com
Tue Apr 7 18:24:18 EDT 2015


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.

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.

On Tue, Apr 7, 2015 at 1:37 PM, Alexander Neundorf <a.neundorf-work at gmx.net>
wrote:

> On Tuesday, April 07, 2015 13:22:30 you wrote:
> > > > > I have a custom executable that does some codegen to produce an
> > > > >
> > >> > > enumeration and a couple of tables.  I need this to be run against
> > >>
> > >> each
> > >>
> > >> > > source file before actual compilation.  It needs include
> directories
> > >>
> > >> and
> > >>
> > >> > > macro definitions from the build system.
> > >> > >
> > >> > > Is there a way to do this with a CMake build system?
> > >>
> > >> add_custom_command
> > >>
> > >> > > seems like it might work, but I need all runs of the custom
> > >>
> > >> executable to
> > >>
> > >> > > run before compilation begins.
> > >> >
> > >> > execute_process() might be what you want:
> > >> > http://www.cmake.org/cmake/help/v3.2/command/execute_process.html
> > >>
> > >> Hmmm, probably add_custom_command() or add_custom_target() is what he
> > >> wants.
> > >> Why does it have to run before the compilation begins ?
> >
> > The program will run once per source file, scan them, and generate a
> header
> > file that is necessary for compilation to succeed.
>
> You could create a add_custom_target(foo); make your actual target depend
> on
> it, so it is finished before the actual compilation starts using
> add_dependencies().
>
> Alex
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150407/7c5dbc6a/attachment.html>


More information about the CMake mailing list