<div dir="ltr"><div style="font-size:12.8px"><br></div><div class="gmail_extra"><div class="gmail_quote">On Wed, Apr 20, 2016 at 4:01 PM, Johan Holmberg <span dir="ltr"><<a href="mailto:johan556@gmail.com" target="_blank">johan556@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>Hi!<br><br></div>How should I setup CMake to build a C/C++ application on Windows using clang/clang++ as compilers and Ninja as build tool?<br><br></div>I tried specifying "-GNinja" to cmake, and setting CC/CXX to clang/clang++. But this didn't work. I get errors like:<br><br> clang.exe: error: no such file or directory: '/nologo'<br><br></div>indicating that CMake thinks it should pass Visual C++ style options to clang.<br><br></div>I'm thinking about fooling CMake that clang/clang++ are cross compilers (I know how to get cross compiling working in other cases). But since clang/clang++ are the native tools for Windows, I was hoping to be able to use Clang + Ninja on Windows almost like I use on Linux.<br><br></div><div>If I run Clang from the command line, I can build my application, so my Clang-installation works.<br></div><div><br></div>I'm using CMake 3.5.1 and Clang 3.8.0.<span class=""><font color="#888888"><br><br></font></span></div><span class=""><font color="#888888">/Johan Holmberg<br><br></font></span></div>
</blockquote></div><br></div><div class="gmail_extra"><div style="font-size:12.8px">Hi,</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">On Windows Clang works only with Visual C++, since they don't provide libc++. MinGW is not supported.</div><div style="font-size:12.8px">Clang provides a Visual C++'s cl.exe replacement.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">You need to have the <a href="http://llvm.org/releases/download.html#3.8.0" target="_blank">official windows</a> Clang and Visual C++ Express or Community installed.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Then it's just a matter of:</div><div style="font-size:12.8px"><ol><li style="margin-left:15px">Opening a Visual C++ 2013 64 bit command prompt window</li><li style="margin-left:15px">Putting clang's cl.exe in the path and setting clang's INCLUDE path first<br><br>set PATH=c:\Program Files\LLVM\msbuild-bin\;%PATH%<br>set INCLUDE=c:\Program Files\LLVM\lib\clang\3.8.0\include\;%INCLUDE%<br><br></li><li style="margin-left:15px">cmake -G "Ninja" </li><li style="margin-left:15px">Ninja</li></ol><div>CMake / Ninja will think that they compile with Visual C++, but instead will use clang.</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Note that you have to match Visual C++ and Clang's build, 32 or 64 bit. You can't mix them,</div><div style="font-size:12.8px">or you'll have <a href="https://cmake.org/pipermail/cmake/2016-March/062978.html" target="_blank">weird errors</a>.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Cheers,</div><div style="font-size:12.8px">Cristian.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">P.S. This is actually a re-post, this time adding the mailing list.</div></div></div>