# Is it safe to delete CMakeCache.txt before each incremental build?

**URL:** https://discourse.cmake.org/t/is-it-safe-to-delete-cmakecache-txt-before-each-incremental-build/1279
**Category:** Usage
**Created:** [May 28, 2020, 9:29am UTC](https://discourse.cmake.org/t/is-it-safe-to-delete-cmakecache-txt-before-each-incremental-build/1279 "2020-05-28T09:29:51Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![KUGA2](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kuga2/32/4968_2.png) [@KUGA2](https://discourse.cmake.org/u/KUGA2)
#### Post date: [May 28, 2020, 9:29am UTC](https://discourse.cmake.org/t/is-it-safe-to-delete-cmakecache-txt-before-each-incremental-build/1279/1 "2020-05-28T09:29:51Z")

</div>

My incremental CI builds frequently get:

```
##[error]CMake Error: Target xxx has dependency information when it shouldn't.
##[error]Your cache is probably stale. Please remove the entry xxx_LIB_DEPENDS from the cache.

```

Is it safe to delete the cache file before each build?  
Will most build binaries be still _up to date_, or will this trigger a full rebuild?

Note: this is a copy of my [SO Question](https://stackoverflow.com/questions/62059747/is-it-safe-to-delete-cmakecache-txt-before-each-incremental-build). I just posted it there first out of habit and forgot about this specialized forum 🙂

---

<div class="post-metadata">

### Author: ![hex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hex/32/363_2.png) [@hex](https://discourse.cmake.org/u/hex)
#### Post date: [May 28, 2020, 10:54am UTC](https://discourse.cmake.org/t/is-it-safe-to-delete-cmakecache-txt-before-each-incremental-build/1279/2 "2020-05-28T10:54:53Z")

</div>

if you delete `CMakeCache.txt` before each build you must make sure to configure and generate cmake. Without it is not “safe” because the cached variables are missing in the next build.

Deleting `CMakeCache.txt` should not affect any binaries, a full rebuild is not triggered. Otherwise you might have a local variable passed on before being cached which then leads to inconsistent runs.

The regeneration of the project can trigger rebuilds if the configuration is different to the previous one.
