My project is build using CMake and is compiled with DistCC + GCC.
I configure the compiler as follows:
SET(CMAKE_C_COMPILER "distcc variation-of-gcc")
# this will use distcc:
make -jXX ...
# this will run locally:
make LOCAL_BUILD=1 -jX ...
The simplest thing to do (IMO) is write a little script in your project that invokes the compiler, and change your cmake files to run that script instead of containing the name of the compiler directly:
Now you can have that script normally run distcc but (based on an environment variable or something) also run without distcc. No need to change anything in your cmake files.