# cmake support for dyndep capability of ninja for own targets

**URL:** <https://discourse.cmake.org/t/cmake-support-for-dyndep-capability-of-ninja-for-own-targets/3378>\
**Category:** Code\
**Tags:** gen:ninja\
**Created:** [May 20, 2021, 1:40pm UTC](https://discourse.cmake.org/t/cmake-support-for-dyndep-capability-of-ninja-for-own-targets/3378 "2021-05-20T13:40:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![FROMAGMA](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/bbce88/32.png) [@FROMAGMA](https://discourse.cmake.org/u/FROMAGMA)\
**Post date:** [May 20, 2021, 1:40pm UTC](https://discourse.cmake.org/t/cmake-support-for-dyndep-capability-of-ninja-for-own-targets/3378/1 "2021-05-20T13:40:44Z")

</div>

Hi,

I know ninja’s dyndep feature is used by cmake for fortran compiling (especially handling modules)  
I would like to use these dyndep feature for the process of generating files in build step (only using ninja).  
But unfortunately I don’t find any cmake commands for using this or for generating these dyndep files.  
Is it possible to build in a “using ninjas dyndep” feature with supporting api?

Thanks in advance and best regards  
Frank

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [May 20, 2021, 2:42pm UTC](https://discourse.cmake.org/t/cmake-support-for-dyndep-capability-of-ninja-for-own-targets/3378/2 "2021-05-20T14:42:16Z")

</div>

No, there is no exposed support for dyndep support in `add_custom_command`. Generally, this requires more infrastructure and would not be a trivial addition.

That said, are you sure you need `dyndep`? What are you doing that you would need it? Usually `add_custom_command(DEPFILE)` would be sufficient.

---

<div class="post-metadata">

**Author:** ![FROMAGMA](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/bbce88/32.png) [@FROMAGMA](https://discourse.cmake.org/u/FROMAGMA)\
**Post date:** [May 20, 2021, 3:35pm UTC](https://discourse.cmake.org/t/cmake-support-for-dyndep-capability-of-ninja-for-own-targets/3378/3 "2021-05-20T15:35:54Z")

</div>

Hi,

Please have a look at:  
[generate files with ninja and cmake](https://github.com/ninja-build/ninja/issues/1972)

We need to generate content from apriori unknown number of files and the output of the generator is also arbitrary.  
We solved this by calling “cmake --build target” in ninja run. Unfortunately from ninja 1.10.0 on the ninja -t restat call breaks our build.  
So we think that using dyndep files would be perfect for our needs, but there is no support in cmake of using this.

Best regards Frank
