[CMake] Using Clang + Ninja on Windows?
Cristian Adam
cristian.adam at gmail.com
Thu Apr 21 17:30:08 EDT 2016
On Wed, Apr 20, 2016 at 4:01 PM, Johan Holmberg <johan556 at gmail.com> wrote:
> Hi!
>
> How should I setup CMake to build a C/C++ application on Windows using
> clang/clang++ as compilers and Ninja as build tool?
>
> I tried specifying "-GNinja" to cmake, and setting CC/CXX to
> clang/clang++. But this didn't work. I get errors like:
>
> clang.exe: error: no such file or directory: '/nologo'
>
> indicating that CMake thinks it should pass Visual C++ style options to
> clang.
>
> 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.
>
> If I run Clang from the command line, I can build my application, so my
> Clang-installation works.
>
> I'm using CMake 3.5.1 and Clang 3.8.0.
>
> /Johan Holmberg
>
>
Hi,
On Windows Clang works only with Visual C++, since they don't provide
libc++. MinGW is not supported.
Clang provides a Visual C++'s cl.exe replacement.
You need to have the official windows
<http://llvm.org/releases/download.html#3.8.0> Clang and Visual C++ Express
or Community installed.
Then it's just a matter of:
1. Opening a Visual C++ 2013 64 bit command prompt window
2. Putting clang's cl.exe in the path and setting clang's INCLUDE path
first
set PATH=c:\Program Files\LLVM\msbuild-bin\;%PATH%
set INCLUDE=c:\Program Files\LLVM\lib\clang\3.8.0\include\;%INCLUDE%
3. cmake -G "Ninja"
4. Ninja
CMake / Ninja will think that they compile with Visual C++, but instead
will use clang.
Note that you have to match Visual C++ and Clang's build, 32 or 64 bit. You
can't mix them,
or you'll have weird errors
<https://cmake.org/pipermail/cmake/2016-March/062978.html>.
Cheers,
Cristian.
P.S. This is actually a re-post, this time adding the mailing list.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160421/e8383756/attachment.html>
More information about the CMake
mailing list