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

Cristian Adam cristian.adam at gmail.com
Fri Jan 29 18:47:49 EST 2016


On 29-Jan-16 19:04, 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.
>
> Thanks,
> Yi-Hong
>

I use clang-cl with ninja.  Open a Visual Studio 2013 command prompt 
window and then set:

$ set PATH=C:\Program Files (x86)\LLVM\msbuild-bin\;%PATH%
$ set INCLUDE=C:\Program Files (x86)\LLVM\lib\clang\3.7.0\include\;%INCLUDE%


The same can be done with Qt Creator and a cloned Visual C++ kit, but in 
the environment settings instead of %PATH% and %INCLUDE% use
$(PATH) and $(INCLUDE).

Cheers,
Cristian.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160130/aa232068/attachment.html>


More information about the CMake mailing list