<div dir="ltr">Hi!<div><br></div><div>I'm pretty new to cmake and I came across a question which I could not find any information about in the official documentation or blog posts.</div><div><br></div><div>When adding a target through add_library / add_executable - should the header files of the target also be listed?</div><div>The question also applies to target_sources I guess.</div><div><br></div><div>On one hand - as far as I can tell it compiles perfectly fine without doing so, and the implicit dependency is also recognized (e.g if the header changes - the target will be recompiled)</div><div>In addition most of the online examples do not list headers.</div><div><br></div><div>On the other hand - it seems wrong not to list them. They ARE part of the target, even if they do not passed to the compiler directly.</div><div>I can also assume that some IDEs will want to know about the existence of these headers and their relationship with the target.</div><div><br></div><div>So what is the correct answer? should header files be listed as part of the target?</div><div><br></div><div>Another question - how does cmake know to create the dependency between the target and the header file, even when it is not listed explicitly?</div></div>