title: Using compiler prefix command(s) with CMake (distcc, ccache)
body: <p>There are utilities which use an existing compiler by adding a command as a prefix (so instead of calling <code>cc -c file.c</code> you could call <code>distcc cc -c file.c</code>).</p>
  
  <p>When using CMake the compiler command can be changed, however I ran into problems trying to use <code>distcc</code>, though this would likely apply to any command prefix to the compiler (<code>ccache</code> too).</p>
  
  <ul>
  <li><p>CMake expects the compiler to be an absolute path,<br>so setting <code>CMAKE_C_COMPILER</code> to <code>/usr/bin/distcc /usr/bin/cc</code>, gives an error:<br></p>
  
  <p><code>/usr/bin/distcc /usr/bin/cc
  is not a full path to an existing compiler tool.</code></p></li>
  <li>Setting the compiler to <code>/usr/bin/distcc</code> and<br><code>CMAKE_C_COMPILER_ARG1</code> or <code>CMAKE_C_FLAGS</code> to begin with <code>/usr/bin/cc</code> works in some cases, but fails with <code>CHECK_C_SOURCE_COMPILES</code><br><em>(checked if there was some way to support this, even prefixing <code>CMAKE_REQUIRED_FLAGS</code> didn't work)</em>.</li>
  </ul>
  
  <hr>
  
  <p>The only way I found to do this is to wrap the commands in a shell script.</p>
  
  <pre><code>#!/bin/sh
  exec /usr/bin/distcc /usr/bin/cc "$@"
  </code></pre>
  
  <p>While this works, It would be nice to be able to use compiler helpers with CMake, without having to go though shell scripts (giving some small overhead when the build system could just use a command prefix).</p>
  
  <hr>
  
  <p>So my question is:</p>
  
  <p>Can CMake use compiler prefix commands (such as distcc) directly?, without shell script wrappers?</p>