I have a large project split up into smaller sub-projects. The dependencies look somewhat like this:
- ext. libs are dependencies from third party sources
- core implements core functionality which is common to several projects.
- lib1/lib2 are the backends and
- app1/app2 the executables
Assume core has some headers which expose types of the ext.lib1, because I need to work with them somewhere else. Now of cause lib1/2 and app1/2 depend on ext.lib1 whenever they use these headers. This happens for every small library I add to one of my libraries, resulting in ever accumulating dependencies further down the tree. All those parts (core, lib, app) are in different cmake projects, because they represent independent logical components and I want to keep them separate, even though they share functionality. Therefore I need a simple way to organize and manage all those libraries and dependencies.
I thought about two different approaches:
Keep ext.libs separate library installations. What I don't like about this is that I end up with lots of loosely coupled dependencies which need to be installed and managed separately and referenced/linked to every other library/executable. This way I end up with a long and redundant dependency lists in every project. Often ext.libs are just smaller header-only libraries which I most rarely want to update (some event contain custom changes) and it would make sense to include them directly into the core lib.
Make it more self-contained and directly put it in the core lib and never touch it again - great! But where? In the core project I can easily create a "libs" folder and put all the different third-party libraries there. However, if I want to use this code from lib1, I end up with ugly long include paths like core/lib/ext.lib1-version/include/ext.lib1/header.h or again I have to set up the include directories for every project separately. But this time I would add sub-paths of already listed paths to the include directories. Is this a common way to do this?
What I'd like to have is the self-containment as in 2. but such that the other projects could just "inherit" the includes and links from core without additional redundant setup, but apparently this only works if all libraries are part of the same cmake project.
Is there a good way how to organize this? Maybe there are better solutions I haven't thought of?