Improve LLVM for Visual Studio compiler detection
I maintained a non-official repository contains LLVM MSBuild script for Visual Studio 2010 to 2019 at https://github.com/zufuliu/llvm-utils
The toolset names are LLVM_v90, LLVM_v100, LLVM_v110, LLVM_v110_xp, LLVM_v120, LLVM_v120_xp, etc (set repository readme). All toolset name suffix are in lower case (_v[0-9]+(_xp)?
).
Currently when running cmake like cmake -Bbuild -H. -A x64 -T LLVM_v142
, the CMAKE_C_COMPILER
and CMAKE_CXX_COMPILER
not detected correctly compared to running cmake -Bbuild -H. -A x64 -T llvm
. MSVC cl.exe is detected in former case, while clang-cl.exe in later case.
See the bug report at
https://github.com/zufuliu/llvm-utils/issues/2
Change (in file Modules/CMakeDetermineCompilerId.cmake)
if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Ll][Ll][Vv][Mm]$")
set(id_cl_var "ClangClExecutable")
to
if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Ll][Ll][Vv][Mm](_v[0-9]+(_xp)?)?$")
set(id_cl_var "ClangClExecutable")
could fix this.
Related bug: #19174 (closed)