[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    Re: [CMake] Prefix header for Makefiles
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2015-08-26 14:43:27
Message-ID: CAExHGmS_+6RrcrXm5-JU8Q7zhE=CwFpPY=8J-mrZnx7kSLTjHg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

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

[Attachment #5 (text/html)]

<div dir="ltr">Hi,<div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug \
26, 2015 at 3:10 PM, Jakob van Bethlehem <span dir="ltr">&lt;<a \
href="mailto:jsvanbethlehem@gmail.com" \
target="_blank">jsvanbethlehem@gmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div style="word-wrap:break-word">Hej \
Andrew,<div><br></div><div>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.</div></div></blockquote><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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.).</div><div><br></div><div>Andreas</div></div></div></div>



-- 

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



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic