From f969f1a9ce1d0045b9d056fd08c4683c34c420fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20D=C3=B6nmez?= Date: Fri, 24 Nov 2017 13:22:46 +0100 Subject: Clang: Do not mistake clang-cl 6.0 for GNU-like clang The check added by commit v3.10.0-rc2~2^2 (Clang: Diagnose unsupported GNU-like clang targeting MSVC ABI, 2017-10-10) is incorrectly detecting clang-cl 6.0 as GNU-like. Currently cmake is testing if the clang compiler accepts `--version` to see if it accepts GNU style flags. However, with the latest llvm snapshot this also works for clang-cl: > clang-cl --version clang version 6.0.0 (trunk) Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: C:\Program Files\LLVM\bin So instead we should use the `/?` flag which fails with clang but works with clang-cl: > clang-cl /? &> /dev/null; echo $? 0 > clang /? &> /dev/null; echo $? 1 Fixes: #17518 --- Modules/CMakeDetermineCompilerId.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 347106e..15c304c 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -742,12 +742,12 @@ function(CMAKE_DIAGNOSE_UNSUPPORTED_CLANG lang envvar) return() endif() - # Test whether a GNU-like command-line option works. - execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" --version + # Test whether an MSVC-like command-line option works. + execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" /? RESULT_VARIABLE _clang_result OUTPUT_VARIABLE _clang_stdout ERROR_VARIABLE _clang_stderr) - if(NOT _clang_result EQUAL 0) + if(_clang_result EQUAL 0) return() endif() -- cgit v0.12