[CMake] Working with dependencies that change

Kenneth Camann kjcamann.lists at gmail.com
Sun Apr 19 12:13:32 EDT 2015


Hi everyone!

I am trying to get a code generation tool to behave "the same as" a C
source file with respect to dependencies. By that I mean, suppose you have
a C file "a.c". Because it can #include files, every time the content of
`a.c` changes, its dependencies may have changed also. The dependencies get
rescanned with -MMD. I would like some way to emulate this for my code
generator.

First I tried add_custom_command, which takes a fixed DEPENDS list,
determined at the time the custom command is defined. Concretely, I mean
something like this:

function(add_generated_library)
  figure_out_dependencies(deps ${ARGN})
  add_custom_command(... DEPENDS ${deps})
  ...
endfunction()

But that only captures the dependencies at build-system-generation time.
Every time the custom command runs, the DEPENDS list may need to change,
because the changes may imply new dependencies.

How should I go about doing this?

Thanks,
Ken
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150419/d1bc991b/attachment.html>


More information about the CMake mailing list