There are utilities that use the existing compiler by adding the command as a prefix (so instead of calling cc -c file.c you can call distcc cc -c file.c ).
When using CMake, the compiler command can be modified, however, I ran into problems trying to use distcc , although this probably applies to any command prefix for the compiler ( ccache too).
CMake expects the compiler to be an absolute path, so setting CMAKE_C_COMPILER to /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.
- Installing the compiler in
/usr/bin/distcc and CMAKE_C_COMPILER_ARG1 or CMAKE_C_FLAGS to start with /usr/bin/cc works in some cases, but with the error CHECK_C_SOURCE_COMPILES
(checked if there is a way to support this even the CMAKE_REQUIRED_FLAGS prefix CMAKE_REQUIRED_FLAGS not work).
The only way I found 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 leaving shell scripts (giving a little overhead when the build system could just use the command prefix).
So my question is:
Can CMake use compiler prefix commands (such as distcc) directly ?, without shell wrapper script?
source share