[CMake][compiler-rt] Support clang-cl in CompilerRTMockLLVMCMakeConfig

clang-cl doesn't support -dumpmachine directly, so we need to
preface it with /clang: in order to get this probing function
to work.

This is needed in order to run cmake directly on the runtimes
directory.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D143557
This commit is contained in:
Tobias Hieta 2023-02-08 09:26:49 +01:00
parent b3477f579c
commit 8ccde9368f
No known key found for this signature in database
GPG Key ID: 44F2485E45D59042

View File

@ -46,8 +46,14 @@ function(compiler_rt_mock_llvm_cmake_config_set_target_triple)
if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang|GNU")
# Note: Clang also supports `-print-target-triple` but gcc doesn't
# support this flag.
set(DUMPMACHINE_ARG -dumpmachine)
if(MSVC)
# This means we are using clang-cl and it requires
# /clang: as prefix for dumpmachine argument.
set(DUMPMACHINE_ARG /clang:-dumpmachine)
endif()
execute_process(
COMMAND "${CMAKE_C_COMPILER}" -dumpmachine
COMMAND "${CMAKE_C_COMPILER}" ${DUMPMACHINE_ARG}
RESULT_VARIABLE HAD_ERROR
OUTPUT_VARIABLE COMPILER_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE)