add_custom_target and add_custom_command

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

add_custom_target and add_custom_command




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.





Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: