[CMake] Correct dependencies in a code generation workflow

Dominic Kempf dominic.r.kempf at gmail.com
Thu Feb 5 13:02:39 EST 2015


Dear CMake list,

I am trying to get a code generating tool chain to work in a cmake based
build system with the Unix Makefiles generator and cmake 2.8.12. Look at
the following MWE of what I am doing:

add_custom_command(OUTPUT generated.hh
                   COMMAND <somecommand>
                   DEPENDS sourcefile)

configure_file(StandardMain.cmake main.cc)

add_executable(target main.cc generated.hh)

generated.hh is generated by a complex command from sourcefile. main.cc is
generated from a template to include the header generated.hh. I can run
"make target" and everything works very nicely: both main.cc and
generated.hh are generated and the target is built.

However, when I touch sourcefile and run make again, generated.hh is
refreshed but the target is not rebuilt although generated.hh has been
specified a source.

I am looking forward to all your helpful responses!! Thanks!

Dominic Kempf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150205/d3e03437/attachment.html>


More information about the CMake mailing list