[CMake] coding style for modules

Craig Scott craig.scott at crascit.com
Thu Jan 4 17:08:01 EST 2018


On Fri, Jan 5, 2018 at 8:09 AM, Alexander Neundorf <a.neundorf-work at gmx.net>
wrote:

> On 2018 M01 4, Thu 05:09:54 CET Dave Milter wrote:
> >
> > c)Include this project as git submodule and use add_subdirectory(libfoo)
>
> the "parent" project will/can influence the behaviour of libfoo then, I
> would
> not recommend this.
>

It depends on the situation, sometimes you explicitly want this. An
advantage of this approach is that libfoo will then be built with the same
set of flags as the main build (apart from those flags it modifies itself).
It also plays nicely with IDE projects because they will typically see all
the sources of libfoo as well as the main project. You can also end up
building just the targets from libfoo that you need instead of building
everything as you would if it was external. The new FetchContent
<https://cmake.org/cmake/help/git-master/module/FetchContent.html> module
(on master, not yet in a public release) makes this approach particularly
easy.

-- 
Craig Scott
Melbourne, Australia
https://crascit.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180105/ebe6beb8/attachment.html>


More information about the CMake mailing list