# Is is possible to cache the \_deps folder?

**URL:** https://discourse.cmake.org/t/is-is-possible-to-cache-the-deps-folder/5276
**Category:** Usage
**Created:** [March 23, 2022, 7:12pm UTC](https://discourse.cmake.org/t/is-is-possible-to-cache-the-deps-folder/5276 "2022-03-23T19:12:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![joefocusrite](https://discourse.cmake.org/user_avatar/discourse.cmake.org/joefocusrite/32/2287_2.png) [@joefocusrite](https://discourse.cmake.org/u/joefocusrite)
#### Post date: [March 23, 2022, 7:12pm UTC](https://discourse.cmake.org/t/is-is-possible-to-cache-the-deps-folder/5276/1 "2022-03-23T19:12:24Z")

</div>

Hi there,

I’m setting up CI for a project. It takes a couple of minutes to generate the project and a lot of that time is spent downloading content using `FetchContent`. Since this content is unlikely to change regularly, it seems like it’s a good candidate to be cached.

CircleCI makes caching easy with its `save_cache` and `restore_cache` commands. These commands take a key to identify the cache, which would typically be some kind of hash of some kind of lock file (e.g. `key: npm-dependencies-{{ checksum "package-lock.json" }}`).

My questions are as follows:

- Is it reasonable to cache the `_deps` folder at all? Will that cause build artefacts to be maintained between runs? Will CMake recognise that it doesn’t need to download the dependencies again?
- Is there some kind of file that I can use as a key that can be used to ‘break the cache’ when a dependency changes?

Thanks!

---

<div class="post-metadata">

### Author: ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)
#### Post date: [March 24, 2022, 1:06am UTC](https://discourse.cmake.org/t/is-is-possible-to-cache-the-deps-folder/5276/2 "2022-03-24T01:06:45Z")

</div>

Yes, it’s absolutely reasonable to cache any fetched dependencies. I usually set `FETCHCONTENT_BASE_DIR` to `projectRoot/Cache`, so that while developing locally I can remove the build tree and dependencies will still be cached for the next CMake run.

Then, with GitHub actions, you can do this:

```auto
- name: Set up cache
        uses: actions/cache@v3
        with:
          path: Cache
          key: ${{ runner.os }}.tests.${{ hashFiles('**/') }}
          restore-keys: ${{ runner.os }}.tests.

```
