# Adding #include-depedencies from add\_custom\_command output to its input

**URL:** <https://discourse.cmake.org/t/adding-include-depedencies-from-add-custom-command-output-to-its-input/4787>\
**Category:** Code\
**Created:** [January 6, 2022, 7:45pm UTC](https://discourse.cmake.org/t/adding-include-depedencies-from-add-custom-command-output-to-its-input/4787 "2022-01-06T19:45:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![EdGore](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/e/db5fbb/32.png) [@EdGore](https://discourse.cmake.org/u/EdGore)\
**Post date:** [January 6, 2022, 7:45pm UTC](https://discourse.cmake.org/t/adding-include-depedencies-from-add-custom-command-output-to-its-input/4787/1 "2022-01-06T19:45:34Z")

</div>

Hello!

I use add\_custom\_command to generate C-Files during the build.  
(if it matters, it’s the Oracle Pro\*C precompiler)

The input and the output file both have #include statements. (Pro\*C is just plain C plus inline SQL code)

When I modify a header which the generated .c file #includes, it’s automatically rebuilt. So far so good, everything works as usual.

But in this case of a modified header, I would also need to re-run the add\_custom\_command, because it also depends on the #included files.

Phrasing it another way - when the output is out-of-date, the input should also be considered out-of-date, too.

Is it possible to apply the rules of automatic #include dependency detection for .c files also to input files of add\_custom\_command?

I don’t want to add a DEPENDS statements to the add\_custom\_command, because those would need to be updated if an #include in the input is updated.  
If this can be done with IMPLICIT\_DEPENDS, could you provide a trivial example?

I am using Unix Makefiles, so if there is no general solution, a solution which only works for Unix Makefiles would suffice.

---

<div class="post-metadata">

**Author:** ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)\
**Post date:** [January 6, 2022, 10:55pm UTC](https://discourse.cmake.org/t/adding-include-depedencies-from-add-custom-command-output-to-its-input/4787/2 "2022-01-06T22:55:28Z")

</div>

No, it is not possible to apply the rules of automatic `#include` dependency detection for `.c` files also to input files of `add_custom_command` but you can use `DEPFILE` option of `add_custom_command` to manage dependencies of your input file.
