clang-cl: Use new value "ClangCl" for CMAKE_<LANG>_COMPILER_ID
With the introduction of clang-cl
on Windows (conditionally) setting compiler-options in CMake became more difficult.
While clang
accepts traditional Clang/GCC options, clang-cl
is a frontend which accepts MSVC options but no longer directly accepts traditional Clang/GCC options.
Now, one not only has to check the CMAKE_<LANG>_COMPILER_ID
variable but additionally CMAKE_<LANG>_COMPILER_FRONTEND_VARIANT
. (See: #22666 (closed))
Even worse, CMake-code that originally worked perfectly fine on different operating systems with different compilers now fails on Windows because it can no longer differentiate between clang
and clang-cl
. This is particularly true when using the generator-expression $<COMPILE_LANG_AND_ID:...>
or $<CXX_COMPILER_ID:...>
etc. (See: #22432)
I therefore suggest to introduce a new value for CMAKE_<LANG>_COMPILER_ID
called "ClangCl
" (similar to "AppleClang
") which shall be used when clang-cl
is used, to simply differentiate between clang
and clang-cl
.
Of course, that should also work with the associated generator-expressions.