[CMake] Should header files be listed for a target?

Avraham Shukron avraham.shukron at gmail.com
Wed Sep 11 15:00:52 EDT 2019


On Wed, Sep 11, 2019 at 9:49 PM Kyle Edwards <kyle.edwards at kitware.com>
wrote:

> You can list them or not list them. CMake will recognize them as header
> files and ignore them (not attempt to compile them.) It's a matter of
> personal preference. CMake's own CMake script lists them, but there are
> plenty of projects that don't and work just fine.


And it far as IDE generators (Xcode, CodeBlocks etc) go - don't they care
about headers?


> > Another question - how does cmake know to create the
> > dependency between the target and the header file, even when it is
> > not listed explicitly?
>
> It uses GCC's -MD and -MF options (and the equivalents for other
> compilers), which spits out the header dependency information.


That is awesome. Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190911/265ab633/attachment.html>


More information about the CMake mailing list