Generated header dependency propagation in object libraries
0 reputation · 08 Apr 2025, 00:44 UTC
When using add_custom_command to produce header files consumed by an object library, incremental builds sometimes fail to trigger a rebuild if the generator source changes. While the DEPENDS clause tracks the input files, the dependency relationship between the generated header and the object files appears inconsistent across different generators.
This behavior is particularly prevalent when using multi-configuration generators where the build directory structure varies by configuration. If the generated header is not explicitly listed as a source in the object library's source files, the build system may rely on stale object files even if the header's modification time has been updated.
How can CMake ensure that an object library correctly registers a dependency on a header file produced by a custom command? r>Is there a specific property to force the dependency scanning of generated files within multi-target hierarchies?