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

2019-09-11 Thread Alexander Neundorf
On Mittwoch, 11. September 2019 21:22:04 CEST Kyle Edwards via CMake wrote:
> On Wed, 2019-09-11 at 22:00 +0300, Avraham Shukron wrote:
> > On Wed, Sep 11, 2019 at 9:49 PM Kyle Edwards  > 
> > m> 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?
> 
> Yes, the headers are more important for IDE generators than they are
> for Make/Ninja (though, AFAIK, they still don't affect the build, just
> the files that the developer sees in the generated project in the IDE.)

it depends.
If you use e.g. the kate project generator, and your project is in svn or git, 
kate retrieves the full list of files via svn/git.
Some generators check whether there is a foo.h in the same directory if there 
is a foo.cpp listed, and add this automatically.

Alex



-- 

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:
https://cmake.org/mailman/listinfo/cmake


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

2019-09-11 Thread Kyle Edwards via CMake
On Wed, 2019-09-11 at 22:00 +0300, Avraham Shukron wrote:
> 
> 
> On Wed, Sep 11, 2019 at 9:49 PM Kyle Edwards  m> 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?

Yes, the headers are more important for IDE generators than they are
for Make/Ninja (though, AFAIK, they still don't affect the build, just
the files that the developer sees in the generated project in the IDE.)

Kyle
-- 

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:
https://cmake.org/mailman/listinfo/cmake


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

2019-09-11 Thread Avraham Shukron
On Wed, Sep 11, 2019 at 9:49 PM Kyle Edwards 
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!
-- 

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:
https://cmake.org/mailman/listinfo/cmake


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

2019-09-11 Thread Kyle Edwards via CMake
On Wed, 2019-09-11 at 21:40 +0300, Avraham Shukron wrote:
> Hi!
> 
> 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.
> 
> When adding a target through add_library / add_executable - should
> the header files of the target also be listed?
> The question also applies to target_sources I guess.
> 
> 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)
> In addition most of the online examples do not list headers.
> 
> 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.
> I can also assume that some IDEs will want to know about the
> existence of these headers and their relationship with the target.
> 
> So what is the correct answer? should header files be listed as part
> of the target?

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.

> 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.

Kyle
-- 

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:
https://cmake.org/mailman/listinfo/cmake


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

2019-09-11 Thread Avraham Shukron
Hi!

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.

When adding a target through add_library / add_executable - should the
header files of the target also be listed?
The question also applies to target_sources I guess.

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)
In addition most of the online examples do not list headers.

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.
I can also assume that some IDEs will want to know about the existence of
these headers and their relationship with the target.

So what is the correct answer? should header files be listed as part of the
target?

Another question - how does cmake know to create the dependency between the
target and the header file, even when it is not listed explicitly?
-- 

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:
https://cmake.org/mailman/listinfo/cmake