title: How to Use CCache with CMake?
body: <p>I would like to do the following: If CCache is present in PATH, use "ccache g++" for compilation, else use g++. I tried writing a small my-cmake script containing </p>
  
  <pre><code>    CC="ccache gcc" CXX="ccache g++" cmake $*
  </code></pre>
  
  <p>but it does not seem to work (running make still does not use ccache; I checked this using CMAKE_VERBOSE_MAKEFILE on). </p>
  
  <p><strong>Update:</strong></p>
  
  <p>As per <a href="http://www.sand-labs.org/owb/wiki/CompilationGuide#Howtospeedupcompilationwithccache" rel="noreferrer">this link</a> I tried changing my script to</p>
  
  <pre><code>     cmake -D CMAKE_CXX_COMPILER="ccache" -D CMAKE_CXX_COMPILER_ARG1="g++" -D CMAKE_C_COMPILER="ccache" -D CMAKE_C_COMPILER_ARG1="gcc" $*
  </code></pre>
  
  <p>but cmake bails out complaining that a test failed on using the compiler ccache (which can be expected).</p>