Organizing a medium size code base for development builds

I have several top level projects that depends on a number of internal and external libraries.

Right now, the top level projects are standardized to a layout like:

  -- libraries
    -- dep1
    -- dep2
    -- dep3
    -- depN
 -- src

all deps are pulled in by git submodule update --init and the build is fine.

Is there a way to support development for the deps (many have common requirements, for instance dep3 may require dep2 to build) while keeping them in the main project build tree?

Ideally, I would like to just cd into the libraries/depN directory and run mkdir build; cd build; cmake ..; make, but I appreciate any other solution involving a reorganization of this layout.

Personally, I find using FetchContent to be a very good fit for that scenario rather than using git submodules. It inherently handles common dependencies like you describe, and it allows the developer to substitute their own local clone of a repo temporarily instead of the one the build asks for (which allows you to work on the main project and dependencies at the same time). Have a read through that module’s docs, including the examples, to see how it can be used. Note that the dependencies sources would no longer appear in your source tree, but rather in the build directory by default. If you want to edit dependencies, don’t edit the ones in the build directory, use a local clone and make use of the FETCHCONTENT_SOURCE_DIR_<DEPNAME> variables to point your build at them.

1 Like

Thanks Craig, this opens even more questions but I will keep them for another topic when I complete a prototype using FetchContent :slight_smile: