Skip to content

Commit 24a1193

Browse files
committed
[cmake] Do not resolve the REALPATH too early.
In some ccache setups we have the compiler soft link to ccache. Eg. /usr/local/bin/g++ -> /usr/local/bin/ccache. If we resolve the link too early we will take the wrong branch assuming the compiler was set as CMAKE_CXX_COMPILER="ccache g++" and try to get the second token of the command.
1 parent 09c767a commit 24a1193

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

interpreter/cling/lib/Interpreter/CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ if (UNIX)
128128

129129
if(NOT CLING_CXX_PATH)
130130
# Remove absolute path from CMAKE_CXX_COMPILER
131-
get_filename_component(_real_cxx_compiler ${CMAKE_CXX_COMPILER} REALPATH)
132-
get_filename_component(_name ${_real_cxx_compiler} NAME)
133-
get_filename_component(_path ${_real_cxx_compiler} PATH)
131+
get_filename_component(_name ${CMAKE_CXX_COMPILER} NAME)
132+
get_filename_component(_path ${CMAKE_CXX_COMPILER} PATH)
134133

135134
# This should probably be more general...but how?
136135
if(_name STREQUAL "ccache" OR _name STREQUAL "distcc")
@@ -198,7 +197,11 @@ if (UNIX)
198197
set(_path "__THISREALLYBETTERNOTBEINPATH_THANKS__")
199198
endif()
200199
else()
201-
get_filename_component(_path ${CMAKE_CXX_COMPILER} PATH)
200+
# FIXME: In some ccache setups we can have a soft link pointing to ccache
201+
# binary. Eg. /usr/local/gcc -> /usr/bin/ccache. Resolving the realpath
202+
# we will get to the ccache and not the intended compiler binary. This
203+
# could be fixed if we run 'gcc -###' which will give us the correct info.
204+
get_filename_component(_path ${CMAKE_CXX_COMPILER} REALPATH)
202205
endif()
203206

204207
# Test if path compiler is on PATH.

0 commit comments

Comments
 (0)