Skip to content

WIP: ExternalProject: add LOCAL_CACHE_DIR

dublet requested to merge dublet/cmake:feature/local-cache-ep into master

RFC: I created this change as it seems like the best way for the build system of my company to avoid needlessly hitting remote servers, without having to do something to populate the DOWNLOAD_DIR. I would like to get some feedback as to whether this is a good way to go, and as such have not implemented any tests, though it is functional.

The ExternalProject module allows for downloading of packages from arbitrary sources. Downloading from sources over the Internet may be slow and place a burden on the remote server.

In order to avoid bandwith and allow a possible quicker incremental build, this commit adds the feature of a local cache directory. This may be set by the CMake script that invokes ExternalProject to a location on a local machine that may or may not contain a copy of the item to be downloaded. If it is not present, it will download as normal and put it in the new location. Any other build could then re-use this already downloaded item without having to access the remote source.

This is most useful when you either have automated continuous integration builds that will otherwise cause excessive use of bandwith, or if the build is set up so that multiple configurations of the same source tree may be built and the binary outputs are different per configuration.

Merge request reports