[CMake] add_subdirectory and common libraries

Craig Scott craig.scott at crascit.com
Mon Dec 11 16:00:20 EST 2017


On Tue, Dec 12, 2017 at 5:13 AM, Harry Mallon <Harry.Mallon at codex.online>
wrote:

> Hello all,
>
> Has anyone got any good recommendations for the following setup?
>
> “large_repo” contains code for a binary and two git submodules. One is
> “library” which is added with add_subdirectory(). The other is some common
> library “util_library” (something like gtest which is generally useful)
> which is added as a git submodule with add_subdirectory(). “library” also
> needs “util_library” which is added to its repo in the same git submodule
> style.
>
> It is possible to namespace the names in an add_subdirectory call? Or
> something like that? Or maybe I should go back to the install and
> find_package() methods I used to use?
>
> ========
> └── large_repo
>     ├── library
>     │   └── util_library
>     └── util_library
> ========
>

It won't really help you right now, but this is a classic scenario that the
new FetchContent module
<https://cmake.org/cmake/help/git-master/module/FetchContent.html> would
address. It's not part of CMake 3.10 but it is on master and should be
available from CMake 3.11 when it is eventually released.


-- 
Craig Scott
Melbourne, Australia
https://crascit.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171212/56cb5677/attachment.html>


More information about the CMake mailing list