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

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
1 Like

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?

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

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

Do you know CPM.cmake


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 :smile: