[CMake] Is there any way to use clang-cl with MSBuild on Windows?

Bill Hoffman bill.hoffman at kitware.com
Fri Jan 29 14:27:42 EST 2016


On 1/29/2016 1:04 PM, Yi-Hong Lyu wrote:
> Hello everyone,
>
> I am a newbie of CMake. I would like to use clang-cl with MSBuild on
> Windows. However it always use MSVC 19.0.23506.0 as the identified
> compiler even I defined CMAKE_C_COMPILER / CMAKE_CXX_COMPILER /
> CMAKE_C_COMPILER_FORCED / CMAKE_CXX_COMPILER_FORCED:
>
> $ cmake -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl
> -DCMAKE_C_COMPILER_FORCED=ON -DCMAKE_CXX_COMPILER_FORCED=ON ..\src\
> -- Building for: Visual Studio 14 2015
> -- The CXX compiler identification is MSVC 19.0.23506.0
> -- The C compiler identification is MSVC 19.0.23506.0
> -- Configuring for standalone build.
> -- Found PythonInterp: C:/Python34/python.exe (found version "3.4.4")
> -- Sphinx disabled.
> .
> .
> .
>
> PS. The environment PATH is already set to clang-cl.
>
> I am wondering whether there is any option that I can force MSBuild use
> clang-cl instead.
>
You could get it to work with ninja, make or nmake.  How does one 
normally force the VS IDE to use the clang compiler?

-Bill



More information about the CMake mailing list