How do I add depencies on header file to custom target

Hey,

How do I add a dependency of a header file to a custom target? Basically I have a header file that contains a few header files. And I want to add all the transitive dependencies to a custom target.

It seems like if I only add the header file CMake won’t pick up all the transitive dependencies.

Thanks

These dependencies are implied by the content of a file, and so are called “implicit dependencies”. CMake models C and C++ preprocessor dependencies (header file inclusion) for rules associated with compiling sources into object files. CMake does not model implicit dependencies in general for arbitrary custom commands.

The add_custom_command documentation does mention the IMPLICIT_DEPENDS option that can be used with Makefile generators. There is also a DEPFILE option for use with Ninja, but the custom command itself is responsible for generating the named file.

Thanks, I’ll take a look at those.