@@ -209,13 +209,22 @@ if (UNIX)
209209 set (_path "__THISREALLYBETTERNOTBEINPATH_THANKS__" )
210210 endif ()
211211 else ()
212- # FIXME: In some ccache setups we can have a soft link pointing to ccache
213- # binary. Eg. /usr/local/gcc -> /usr/bin/ccache. Resolving the realpath
214- # we will get to the ccache and not the intended compiler binary. This
215- # could be fixed if we run 'gcc -###' which will give us the correct info.
216212 get_filename_component (_realpath ${CMAKE_CXX_COMPILER} REALPATH)
217- get_filename_component (_name ${_realpath} NAME )
218- get_filename_component (_path ${_realpath} PATH )
213+ if (${_realpath} MATCHES "ccache" OR ${_realpath} MATCHES "distcc" )
214+ # In some setups we can have a soft link pointing to ccache binary.
215+ # Eg. /usr/local/gcc -> /usr/bin/ccache where /usr/local comes first
216+ # in the PATH env variable than /usr/bin. Resolving the realpath
217+ # got us to the ccache and not the intended compiler binary, i.e.
218+ # CLING_CXX_RLTV will be wrong. As a fallback / best-effort basis,
219+ # try to rescue the compiler binary name by looking at the
220+ # link name rather than at the the link destination.
221+ get_filename_component (_realpath ${CMAKE_CXX_COMPILER} PATH )
222+ get_filename_component (_name ${CMAKE_CXX_COMPILER} NAME )
223+ get_filename_component (_path ${CMAKE_CXX_COMPILER} PATH )
224+ else ()
225+ get_filename_component (_name ${_realpath} NAME )
226+ get_filename_component (_path ${_realpath} PATH )
227+ endif ()
219228 endif ()
220229
221230 # Test if path compiler is on PATH.
0 commit comments