45

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?

CXJ
  • 4,301
  • 3
  • 32
  • 62
Arkadi Sim
  • 553
  • 1
  • 4
  • 7

2 Answers2

70

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.
marco.m
  • 4,573
  • 2
  • 26
  • 41
  • 1
    The message explicitly states this, but just be aware that this clears your local history. If you don't want to do this, you can try Cristian Bidea's suggestion to delete the CMakeCache.txt – Christopher Schneider May 21 '15 at 17:42
  • 2
    Note that "Invalidate and restart" will delete the cache for all of your CLion projects, not just the currently open one. Also, sometimes I've had to manually cleanup the residue left after this operation and/or re-import projects. – silentorb Sep 07 '15 at 17:34
  • For me using CLion 1.1 on Windows, deleting CMakeCache.txt prevents the project from building until the file is restored. – silentorb Sep 07 '15 at 17:34
  • Have updated Mac OS X El Capitan then encountered the issue that: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk" path not found so this command solved the issue! Thanks. – Gencebay Sep 20 '15 at 19:07
  • I did a "reset cache and reload project", and now clion no longer calls cmake to regenerate make files: `Error:ERROR null: No cmake script provided. ERROR null: Problem processing arguments. Aborting.` Do you know how I can solve this problem? – DaveFar Mar 09 '16 at 19:59
  • @DaveFar: You followed suggestion 1. My answer says: "if that for some reasons is not enough, ..." Did you try suggestion 2 ? – marco.m Mar 09 '16 at 20:40
  • @marco.m: yes, I also tried suggestion 2, and it did not solve my problems, i.e. i still get the same ERROR message. – DaveFar Mar 10 '16 at 12:13
1

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.

Equidamoid
  • 1,447
  • 1
  • 13
  • 24