I have a C++ project that builds using CMake. I usually build on OSX but now I am trying to get a Windows version working too. I would like to use Clang on Windows for compatibility reasons.
I installed the pre-compiled Clang 3.8 binary from LLVM:
C:\Program Files\LLVM\bin\clang.exe
C:\Program Files\LLVM\bin\clang++.exe
It is also installed on my PATH:
>clang++
clang++.exe: error: no input files
I have two questions:
- How do I tell CMake to use
clang++
when I callcmake --build
? - How can I check before building which compiler CMake is configured with?
You also need - in addition to the Clang compilers itself - an build/link environment for Windows.
The latest CMake 3.6 builds do have several integrated supported Clang build environments on Windows (e.g. Visual Studio, Cygwin; see Release Notes).
I've just run a successful test with
All installed to their standard paths with their
bin
directories in the globalPATH
environment.The part you need to know is setting the right toolset with the CMake
-T"LLVM-vs2014"
command line option. During the configuration process CMake will let you know which compiler it has found/taken.CMakeLists.txt
Windows Console
Installation Hints
Please note that I have added LLVM to my search paths during setup:
And you can crosscheck the available "Platform Toolsets" in any VS project's property page:
References