cmake, ccache, CCACHE_BASEDIR: wrong paths in compiler error messages

As far as I am aware, you are correct the design goal of CCACHE_BASEDIR is to solve this problem.

A couple of things:

  1. You can try the ninja generator it has a consistent build directory for all invocations
  2. 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 )
  3. 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.