How to use ccache?

In the wiki ( there is note about ccache. It’s written that if ccache was found in $PATH, it would be used, but it isn’t. (To work, compile command should use ccache $CXX instead of $CXX, but I see it still runs g++ with no ccache).
Using /usr/bin/ccache g++ as c++ compiler is not possible with CMake.
What I’m doing wrong?