[CMake] Update and build child projects if a parent (dependency) is updated

Craig Scott craig.scott at crascit.com
Wed Feb 7 16:53:19 EST 2018


On Thu, 8 Feb 2018 at 4:52 am, Saad Khattak <saadrustam at gmail.com> wrote:

> Hi,
>
> I have a lot of projects with many dependencies. Support ProjE depends on
> ProjD which in turn depends on ProjB and ProjC where ProjB depends on ProjA.
>
> If ProjA, is updated, I would like some way to trigger the generate/build
> (or just build, assuming the projects are already generated) ProjB, ProjD
> and ProjE (not ProjC as it did not depend on ProjA).
>
> I realize this is not possible without ProjA somehow knowing about its
> dependent projects. And so I don't mind if it's a new master project or
> super build. What I would like however is for CMake to generate this master
> project for me (as it already knows the dependency hierarchy). Then, it'll
> just be a matter of building this 'superbuild' which in turn detects that
> ProjA has been updated, and updates/builds all its dependents.
>
> I can do this manually by ExternalProject_Add, but that is just error
> prone and not at all automated. If the projects go into the double or
> triple digit range, you can see why manually preparing the superbuild
> project is not a good solution.
>

An alternative to the superbuild approach is the new FetchContent module
that has been added in the upcoming 3.11 release. You can see the docs for
it here:

https://cmake.org/cmake/help/git-master/module/FetchContent.html

It may be more convenient for the situation you describe. There’s even a
somewhat similar example in those docs for inter project dependencies along
the lines of your case.



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


More information about the CMake mailing list