# \`add\_custom\_command\` and Generated Header Dependencies

**URL:** https://discourse.cmake.org/t/add-custom-command-and-generated-header-dependencies/7393
**Category:** Usage
**Tags:** gen:ninja
**Created:** [February 2, 2023, 9:57pm UTC](https://discourse.cmake.org/t/add-custom-command-and-generated-header-dependencies/7393 "2023-02-02T21:57:31Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![marstaik](https://discourse.cmake.org/user_avatar/discourse.cmake.org/marstaik/32/2230_2.png) [@marstaik](https://discourse.cmake.org/u/marstaik)
#### Post date: [February 2, 2023, 11:25pm UTC](https://discourse.cmake.org/t/add-custom-command-and-generated-header-dependencies/7393/2 "2023-02-02T23:25:00Z")

</div>

Solution:

Following this post with the new File sets: [How to install an interface library with generated source in build folder - #2 by ben.boeckel](https://discourse.cmake.org/t/how-to-install-an-interface-library-with-generated-source-in-build-folder/5449/2)

I was able to get around this by creating an interface library with a generated name “${target}\_gen\_lib”, and then put the generated files into the fileset of the interface library.

adding `target_link_libraries(${target} ${target}_gen_lib)` then allows everything to work, since the gen\_lib target must be completed before ${target} is run.

---

_[View the full topic](https://discourse.cmake.org/t/add-custom-command-and-generated-header-dependencies/7393)._
