# Organizing a medium size code base for development builds

**URL:** <https://discourse.cmake.org/t/organizing-a-medium-size-code-base-for-development-builds/4450>\
**Category:** Code\
**Created:** [November 8, 2021, 7:02pm UTC](https://discourse.cmake.org/t/organizing-a-medium-size-code-base-for-development-builds/4450 "2021-11-08T19:02:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![giallu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/giallu/32/1938_2.png) [@giallu](https://discourse.cmake.org/u/giallu)\
**Post date:** [November 8, 2021, 7:02pm UTC](https://discourse.cmake.org/t/organizing-a-medium-size-code-base-for-development-builds/4450/1 "2021-11-08T19:02:32Z")

</div>

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:

```auto
project
  -- 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.

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [November 8, 2021, 10:05pm UTC](https://discourse.cmake.org/t/organizing-a-medium-size-code-base-for-development-builds/4450/2 "2021-11-08T22:05:34Z")

</div>

Personally, I find using [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) 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.

---

<div class="post-metadata">

**Author:** ![giallu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/giallu/32/1938_2.png) [@giallu](https://discourse.cmake.org/u/giallu)\
**Post date:** [November 11, 2021, 8:18am UTC](https://discourse.cmake.org/t/organizing-a-medium-size-code-base-for-development-builds/4450/3 "2021-11-11T08:18:09Z")

</div>

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