Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear CMake cache in Clion?

Tags:

cmake

clion

I am currently trying to swap static libraries in one of my projects which requires swapping find_package() commands for explicit links to static libraries. One of the problems I encountered is that even after deleting find_package() commands reloading the CMake Project the old variables are still present.

Is there a way to explicitly flush the CMake cache other than manually deleting all files from the temporary folder Clion creates for building the project?

like image 344
Arkadi Sim Avatar asked Dec 17 '14 12:12

Arkadi Sim


People also ask

How to reset the CMake cache without affecting the CLion cache?

If required, you can open and edit CMakeCache.txt as a regular text file. For this, use the icon in the CMake Tool Window or locate the file in the project tree. To reset the CMake cache without affecting the CLion cache, do one of the following:

What happens when I invalidate the cache in CLion?

When you invalidate the cache, CLion removes the cache files for all projects ever run in the current version of the IDE. The files will be recreated the next time you open these projects. The caches will not be deleted until you restart CLion.

How do I edit the cmakecache file?

If required, you can open and edit CMakeCache.txt as a regular text file. For this, use the icon in the CMake Tool Window or locate the file in the project tree. To reset the CMake cache without affecting the CLion cache, do one of the following: Call Tools | CMake | Reset Cache and Reload Project.

Where does CMake cache variables and settings?

CMake caches variables and settings in the CMakeCache.txt file. When you load a project for the first time, this file is generated in the build directory ( cmake-build-debug or cmake-build-release by default) according to the contents of CMakeLists.txt.


2 Answers

Starting with CLion 1.5 144.3143 (2016-01-20), you can clear the cmake cache without loosing the CLion indexes and without restarting (meaning: very fast, also on huge projects):

Tool | CMake | "Reset cache and reload project". 

If that for some reasons is not enough, or if you have an older CLion, you can do the more radical:

File | "Invalidate Caches / Restart"  

and click on "Invalidate and restart".

EDITS

  • 2016-01-20: add the faster method available with newer CLion.
like image 164
marco.m Avatar answered Sep 18 '22 19:09

marco.m


There is some magic with this cache. I got bad value for one variable once: by some reason cmake found some wrecked freetype includes inside mono.framework (another reason to dislike mono...) and tried to use them to compile my project. Obviously compilation failed.

I tried to remove CMakeCache.txt and rebuild project but incorrect path come back. Even after I removed mono.framework dir!

The solution was to remove incorrect line from the cache and restart the build. After that cmake got the correct path and build succeded.

UPD: After I "reload cmake project" incorrect value came back. Deleting everything in $HOME/Library/Caches/clion11/cmake/generated/ dir (for OS X) seems to finally solve the issue.

like image 40
Equidamoid Avatar answered Sep 21 '22 19:09

Equidamoid