I am trying to use ccache with CMake. I have placed symlinks named gcc, g++ and c++ in /usr/local/bin. If I run make, add some change to CMakeLists.txt that does not affect the compiled files (add unused library just to force make build all the targets) and re-run make, everything is recompiled as if there was no ccache. However, if I remove all CMake-generated files and then call cmake; make, everything works fine, and object files are retrieved from cache, even if I change CMakeLists.txt.
Looks like something CMake-generated prevents hitting the cache. I tried searching through verbose output of both make and cmake, but could not find any dependencies that could cause this behaviour.