As far as I am aware, you are correct the design goal of CCACHE_BASEDIR
is to solve this problem.
A couple of things:
- You can try the ninja generator it has a consistent build directory for all invocations
- You might not be getting cache hits because the
-g
or__FILE__
macros are still being used in the hash computation ( see https://ccache.dev/manual/latest.html#_compiling_in_different_directories ) - IDE’s shouldn’t be parsing the makefile output. They should be using CMake file-api or a compile_commands.json. Both of those shouldn’t be effected by ccache.