C and C++ are not the only languages supported by cl.exe-compatible compilers
CMake refuses to use the GCC-compatible clang driver on Windows and so forces the use of clang-cl.exe. This driver supports C and C++, but also supports Objective-C, Objective-C++, and GNU-style assembly with or without the C preprocessor. Clang/CX (the clang front end with the Visual Studio code generator) also supports Objective-C. Unfortunately, CMake adds one of either the /TC (interpret source as C) or /TP (interpret source as C++) flags unconditionally and does not provide a way of turning this off. This makes it impossible to use CMake with clang on Windows for any languages other than C or C++. It is doubly annoying because these flags are completely pointless in most cases, because both cl.exe and clang-cl.exe will auto-detect C and C++ sources based on their file extension.
There is also some inconsistency, because the Ninja code generator uses -TP and -TC, whereas the msbuild code generators use /TP and /TC.
You can work around this in a really ugly way with clang by setting the undocumented CCC_OVERRIDE_OPTIONS
environment variable to x/TC x/TP x-TC x-TP
, to tell the clang driver to strip these flags before starting argument parsing. Unfortunately, you can't set this reliable from CMake, because environment variables set in the CMake configuration are set the first time that you build (and are set in any build that reruns cmake), but are not set in either msbuild or ninja incremental builds.