Raul Laasner
Raul Laasner

Reputation: 1585

Why is the cache sometimes reset?

For example, when I change the compiler, the whole cache is deleted and needs to be reconfigured. I understand that things like the compiler flags would need to be reset but why the whole cache?

Upvotes: 0

Views: 1030

Answers (1)

Florian
Florian

Reputation: 42922

Turning my comment into an answer

The Message itself

The CMake message

"You have changed variables that require your cache to be deleted. Configure will be re-run and you may have to reset some variables. The following variables have changed: ..."

translates to something like

"CMake tries to behave and is not telling you that for a change like that you have to delete your binary output directory and start from scratch again."

This feature came a long time ago with "ENH: fix for bug 6102, allow users to change the compiler" commit and was improved with "Delete entire CMakeFiles directory when deleting CMakeCache.txt" commit:

Fix this simply by teaching cmCacheManager::DeleteCache to remove the entire CMakeFiles directory recursively whenever it removes an existing CMakeCache.txt. This fully resets the build tree to configure with a fresh compiler.

Why does it have to delete everything?

If you change the compiler or upgrade to a newer version of CMake, your generated build environment could not just simply be adapted.

All cached configurations - as being an evaluation or search results based on the compiler and platform information - have to be deleted and re-run. CMake could simply not know which cached variable is still valid in the new environment.

Upvotes: 1

Related Questions