# Feature-Idea: \`FetchContent\` allow configurable '{target}-src' folder i.e. Allow single source clone across build configurations

**URL:** https://discourse.cmake.org/t/feature-idea-fetchcontent-allow-configurable-target-src-folder-i-e-allow-single-source-clone-across-build-configurations/4213
**Category:** Development
**Created:** [October 6, 2021, 8:18am UTC](https://discourse.cmake.org/t/feature-idea-fetchcontent-allow-configurable-target-src-folder-i-e-allow-single-source-clone-across-build-configurations/4213 "2021-10-06T08:18:45Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![CraigEmteq](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craigemteq/32/1229_2.png) [@CraigEmteq](https://discourse.cmake.org/u/CraigEmteq)
#### Post date: [October 6, 2021, 8:18am UTC](https://discourse.cmake.org/t/feature-idea-fetchcontent-allow-configurable-target-src-folder-i-e-allow-single-source-clone-across-build-configurations/4213/1 "2021-10-06T08:18:45Z")

</div>

# Perceived issue with `FetchContent`

In a multi configuration build e.g. Windows+Android+Linux any fetched repository is Clone separately into every build folder.

- Duplicate bandwidth for download/update of each configuration
- Duplicate storage use on disk of each configuration

# Current State

- `FETCHCONTENT_BASE_DIR` can be used to change ALL directories which is not workable as this means that `build` folders are also shared erroneously.

# Concept of a Solution

If the `FetchContent` supported a `FETCHCONTENT_SOURCE_BASE_DIR` override then all configurations could place the src into the same configured directory.

# Extending of Solution

If a out-of-build folder e.g. User-Home location is used for source then there could be a centralised storage of `FetchContent` modules on a users computer.

- These could allow ‘always offline’ to still work after a ‘clean’ operation has occured
- This doens’t consider how/if multiple versions of the same module should be catered for, however it is the _users choice to set the SOURCE\_BASE\_DIR_

---

<div class="post-metadata">

### Author: ![codeling](https://discourse.cmake.org/user_avatar/discourse.cmake.org/codeling/32/1700_2.png) [@codeling](https://discourse.cmake.org/u/codeling)
#### Post date: [October 6, 2021, 9:19am UTC](https://discourse.cmake.org/t/feature-idea-fetchcontent-allow-configurable-target-src-folder-i-e-allow-single-source-clone-across-build-configurations/4213/2 "2021-10-06T09:19:28Z")

</div>

I would love something similar for `ExternalProject_Add` as well - in testing our superbuild on a routine basis, I want to start it from scratch, but on the other hand, I don’t want to waste network bandwith by downloading the same external project archive files over and over again…

Could that be made into a generic download pool maybe? Or is there already a solution for that applicable to `ExternalProject_Add` that I’ve overlooked?

---

<div class="post-metadata">

### Author: ![codeling](https://discourse.cmake.org/user_avatar/discourse.cmake.org/codeling/32/1700_2.png) [@codeling](https://discourse.cmake.org/u/codeling)
#### Post date: [October 6, 2021, 9:40am UTC](https://discourse.cmake.org/t/feature-idea-fetchcontent-allow-configurable-target-src-folder-i-e-allow-single-source-clone-across-build-configurations/4213/3 "2021-10-06T09:40:03Z")

</div>

Scratch that - on checking the docs again I realized that `DOWNLOAD_DIR` does exactly what I want for `ExternalProject_Add` - sorry for the noise!

---

<div class="post-metadata">

### Author: ![CraigEmteq](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craigemteq/32/1229_2.png) [@CraigEmteq](https://discourse.cmake.org/u/CraigEmteq)
#### Post date: [October 6, 2021, 9:49am UTC](https://discourse.cmake.org/t/feature-idea-fetchcontent-allow-configurable-target-src-folder-i-e-allow-single-source-clone-across-build-configurations/4213/4 "2021-10-06T09:49:13Z")

</div>

Thanks, you made me realise that maybe `SOURCE_DIR` per `ExternalProject` maybe what I need also instead of some method to set it globally.

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [October 19, 2021, 5:53pm UTC](https://discourse.cmake.org/t/feature-idea-fetchcontent-allow-configurable-target-src-folder-i-e-allow-single-source-clone-across-build-configurations/4213/5 "2021-10-19T17:53:27Z")

</div>

Do you know [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake#comparison-to-pure-fetchcontent--externalproject)

---

<div class="post-metadata">

### Author: ![CraigEmteq](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craigemteq/32/1229_2.png) [@CraigEmteq](https://discourse.cmake.org/u/CraigEmteq)
#### Post date: [October 20, 2021, 8:19am UTC](https://discourse.cmake.org/t/feature-idea-fetchcontent-allow-configurable-target-src-folder-i-e-allow-single-source-clone-across-build-configurations/4213/6 "2021-10-20T08:19:06Z")

</div>

Thanks @ClausKlein I will take a look. Get the initial feeling it looks to try and encapsulate the FetchContent in more of a manner I was looking for 😄
