Hi,

On Wed, Aug 26, 2015 at 3:10 PM, Jakob van Bethlehem <
jsvanbethle...@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
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to