Skip to content

Commit f98c325

Browse files
authored
Merge pull request #7302 from erg/cmake-benchmark-find-clang
benchmark/CMakeLists.txt: Accept the --host-cc clang path if provided
2 parents 72f7bee + 307506c commit f98c325

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

benchmark/CMakeLists.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,18 @@ if(NOT SWIFT_LIBRARY_PATH)
139139
set(SWIFT_LIBRARY_PATH "${tmp_dir}/lib/swift")
140140
endif()
141141

142-
runcmd(COMMAND "xcrun" "-toolchain" "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" "-f" "clang"
143-
VARIABLE CLANG_EXEC
144-
ERROR "Unable to find Clang driver")
142+
# If the CMAKE_C_COMPILER is already clang, don't find it again,
143+
# thus allowing the --host-cc build-script argument to work here.
144+
get_filename_component(c_compiler ${CMAKE_C_COMPILER} NAME)
145+
146+
if(${c_compiler} STREQUAL "clang")
147+
set(CLANG_EXEC ${CMAKE_C_COMPILER})
148+
else()
149+
runcmd(COMMAND "xcrun" "-toolchain" "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" "-f" "clang"
150+
VARIABLE CLANG_EXEC
151+
ERROR "Unable to find Clang driver")
152+
endif()
153+
145154

146155
# You have to delete CMakeCache.txt in the swift build to force a
147156
# reconfiguration.

0 commit comments

Comments
 (0)