There are utilities which use an existing compiler by adding a command as a prefix (so instead of calling cc -c file.c you could call distcc cc -c file.c).
When using CMake the compiler command can be changed, however I ran into problems trying to use distcc, though this would likely apply to any command prefix to the compiler (ccache too).
CMake expects the compiler to be an absolute path,
so settingCMAKE_C_COMPILERto/usr/bin/distcc /usr/bin/cc, gives an error:/usr/bin/distcc /usr/bin/cc is not a full path to an existing compiler tool.- Setting the compiler to
/usr/bin/distccandCMAKE_C_COMPILER_ARG1orCMAKE_C_FLAGSto begin with/usr/bin/ccworks in some cases, but fails withCHECK_C_SOURCE_COMPILES
(checked if there was some way to support this, even prefixingCMAKE_REQUIRED_FLAGSdidn't work).
The only way I found to do this is to wrap the commands in a shell script.
#!/bin/sh
exec /usr/bin/distcc /usr/bin/cc "$@"
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).
So my question is:
Can CMake use compiler prefix commands (such as distcc) directly?, without shell script wrappers?