On Wed, Apr 20, 2016 at 4:01 PM, Johan Holmberg <johan...@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.
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake