[CMake] add_custom_target and add_custom_command

csiga.biga at aol.com csiga.biga at aol.com
Sat Mar 18 11:16:10 EDT 2017


Hi!

Apologies for the noobish question, but even a seasoned CMake user can get lost from time to time.

I want to demonstrate the feasability of automating an article creation proces with CMake. Ultimately I want to issue commands as such on the CLI:

make app
make data
make plot
make article

These commands would:

compile a C/C++ application (no problem)
invoke that app with some args (provided by CMake) to create a data file (only if the app or the args have changed)
invoke a gnuplot script on the data file to create a plot (only if the the data file or the plotting script have changed)
invoke latex to create a document that references the plot (only if either the latex file or the plot changed)

Because any of the steps may take fairly lone, I would like each pass to do something only if any of the preceding steps are out of date. I sort of got lost in the custom_target and custom_command functions and how and when to use them to setup a chain of custom tool invocation that have well defined input and output files.

Could someone show a real simple demo?

Help is much appreciated.

Cheers,
Máté
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170318/1ed2e020/attachment.html>


More information about the CMake mailing list