[CMake] Prefix header for Makefiles

Andreas Pakulat apaku at gmx.de
Wed Aug 26 10:43:27 EDT 2015


Hi,

On Wed, Aug 26, 2015 at 3:10 PM, Jakob van Bethlehem <
jsvanbethlehem at gmail.com> wrote:

> Hej Andrew,
>
> CMake does never scan source files (as far as I know), as it is not a
> compiler. From your question it almost seem you are making this assumption,
> so I just wanted to make sure to mention at least this.
>

Thats wrong, CMake has to parse the source files you add to a target to be
able to determine its dependencies (recursively) so it can generate
makefile rules that ensure that if one of the (indirectly) included headers
changes the source file is recompiled. You can see this in cmDependsC.cxx
in the CMake sources for C (and possibly C++) source files.

It of course does not parse the C/C++ code, it merely finds lines that
start with #include or #import and figures out the absolute path of the
mentioned header file based on the targets include directories.

Of course you can help CMake here by specifying all headers in the
add_executable/add_library call, but that easily ends up being a
maintenance nightmare for files outside of your actual project (system
headers, third-party libraries etc.).

Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150826/8315f945/attachment.html>


More information about the CMake mailing list