Fix building with USECCACHE=1.

This fixes the variable expansion and building with CMake.
Merge pull request #8906 from maleadt/pr_ccache

Fix building with USECCACHE=1.