Avoid a recursion when using ccache and/or distcc: Set the ccache prefix by means of RULE_LAUNCH_COMPILE and RULE_LAUNCH_LINK only, if the environment's variable CXX is not already a symbolic link to ccache. --- CMakeLists.txt +++ CMakeLists.txt @@ -137,8 +137,14 @@ find_program(CCACHE_FOUND ccache) if(CCACHE_FOUND) set(ENV(CCACHE_CPP2) "yes") - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + get_filename_component(CXX_SYMLINK $ENV{CXX} REALPATH) + if(CXX_SYMLINK MATCHES ".*/ccache") + message(STATUS "Found ccache symlinks method (CXX_SYMLINK is ${CXX_SYMLINK})") + else(CXX_SYMLINK MATCHES ".*/ccache") + message(STATUS "Enabling ccache (${CCACHE_FOUND})") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + endif(CXX_SYMLINK MATCHES ".*/ccache") endif(CCACHE_FOUND) if (GLEW_FOUND OR EPOXY_FOUND)