Ninja generator fails with clang-cl when mixing 64/32 bit clang and Visual Studio Envornment
The ninja generator is able to build project with clang-cl when used with the matching visual studio toolchain.
So with a 64 bit clang-cl executable, the following succeeds:
call "%VS140COMNTOOLS%..\\..\\VC\\vcvarsall.bat" x86_amd64 set CC=clang-cl set CXX=clang-cl cmake ../ -GNinja
And with the 32 bit clang-cl executable, only the 32 bit toolchain (x86) can be used.
This isn't a limitation with the Visual Studio generator, which is able to build both 32 and 64 bit projects using both 32 and 64 bit clang-cl executables. (It is because the clang-cl toolchain files are specified for both 32 bit and 64 bit environments, specifying the -m32 and -m64 flags.
The ninja generator should:
- Detect clang with passing the -m32 or -m64 flags just like for gcc / plain clang. This is required as without this CMake isn't able to build a 64 bit executable with 32 bit clang or the other way around.
- Specify an MSVC compatibility flag (also added by the same toolchain), e.g. -fmsc-version=1900. This is optional, as this can be added later in the CMakefile after detecting that the compiler is indeed clang.