I am trying to call "Clang compiler for Windows" installed by Visual Studio Installer from cmake command line. According to the platform toolset of an opned .sln
file, this shall be clang-cl
, but neither setting the -T
flag of cmake to clang-cl
nor LLVM
works.
Asked
Active
Viewed 779 times
1

march_happy
- 420
- 5
- 11
-
You should use `-DCMAKE_CXX_COMPILER=clang-cl` rather than `-T clang-cl`. – Mr Qian Jan 14 '20 at 06:18
1 Answers
4
What is the Platform Toolset name of LLVM installed by Visual Studio Installer in VS 2019?
For your situation, you cannot use "-T" to call the clang-cl
and it is not in the supported toolset. You can use DCMAKE_CXX_COMPILER
directly.
-T Toolset specification for the generator, if supported.
Some CMake generators support a toolset specification to tell the native build system how to choose a compiler. See the CMAKE_GENERATOR_TOOLSET variable for details.
Solution
Please try this:
cmake -G "Visual Studio 16 2019" -DCMAKE_CXX_COMPILER=clang-cl -p "CMakeLists.txt"
More info you can refer to this.
Update 1
It can be realized by -T
and use clangcl
instead of clang-cl
. In toolset, LLVM is called clangcl
.
cmake -G "Visual Studio 16 2019" -T clangcl
Hope it could help you.

Mr Qian
- 21,064
- 1
- 31
- 41
-
Just a side note here: Indeed it is possible to use -T flag, but instead of ```clang-cl```, Visual Studio uses ```clangcl```. – march_happy Jan 15 '20 at 12:33
-
Thanks for your reminder. And l have added it in my answer. Thanks a lot. – Mr Qian Jan 16 '20 at 03:17