title: clang++ in CLion Windows, how to run with MinGW--w64 instead of Windows VC?
body: <h1>What I have</h1>
  
  <ul>
  <li>Windows 10 x64</li>
  <li>MinGW-w64 toolchain 7.3.0, 32+64, 64bit version set in PATH</li>
  <li>CLang Windows distribution 6.0.0, 32+64, 64bit version set in PATH</li>
  <li>CLion 2018.1 &amp; built-in cmake</li>
  <li>Set CMake preference inside CLion <a href="https://intellij-support.jetbrains.com/hc/en-us/community/posts/206606735-Using-Clang-With-CLion-on-Windows?page=1#community_comment_115000631284" rel="nofollow noreferrer">following this post</a></li>
  <li><strong>Will not</strong> installed VS or VS build tools.</li>
  <li>Can compile cpp files from command line with both <code>g++</code> and <code>clang++</code> without error. For <code>clang++</code> I have to set flag <code>-target x86_64-pc-mingw64</code> due to lack of VC toolchain and headers.</li>
  </ul>
  
  <h1>What I want</h1>
  
  <p>Set a functional CMake profile using <code>clang++</code> compiler.</p>
  
  <p>I have set a CMake profile according to the link above. However, clion give error</p>
  
  <pre><code>The Clang compiler tool
  "C:/Program Files/LLVM/bin/clang.exe"
  
  targets the MSVC ABI but has a GNU-like command-line interface.  This is
  not supported.  Use 'clang-cl' instead, e.g.  by setting 'CC=clang-cl' in
  the environment.  Furthermore, use the MSVC command-line environment.
  </code></pre>
  
  <p>If I set C and CXX COMPILERs to <code>clang-cl</code> instead of setting TOOLCHAIN PREFIX to <code>LLVM</code>, there will be an error.</p>
  
  <pre><code>CMake Error at C:/Program Files/JetBrains/CLion 
  2018.1/bin/cmake/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 
  (message):
  The C compiler
  
  "C:/Program Files/LLVM/bin/clang-cl.exe"
  
  is not able to compile a simple test program.
  
  It fails with the following output:
  
  Change Dir: C:/Users/huang/Documents/Programs/grade/cmake-build-release-
  clang-1/CMakeFiles/CMakeTmp
  
  Run Build Command:"C:/mingw64/bin/mingw32-make.exe" "cmTC_181bf/fast"
  C:/mingw64/bin/mingw32-make.exe -f CMakeFiles\cmTC_181bf.dir\build.make 
  CMakeFiles/cmTC_181bf.dir/build
  mingw32-make.exe[1]: Entering directory 
  'C:/Users/huang/Documents/Programs/grade/cmake-build-release-clang-
  1/CMakeFiles/CMakeTmp'
  Building C object CMakeFiles/cmTC_181bf.dir/testCCompiler.c.obj
  C:\PROGRA~1\LLVM\bin\clang-cl.exe  /nologo   /DWIN32 /D_WINDOWS /W3  /MDd 
  /Zi /Ob0 /Od /RTC1   /FoCMakeFiles\cmTC_181bf.dir\testCCompiler.c.obj 
  /FdCMakeFiles\cmTC_181bf.dir/ -c 
  C:\Users\huang\Documents\Programs\grade\cmake-build-release-clang-
  1\CMakeFiles\CMakeTmp\testCCompiler.c
  Linking C executable cmTC_181bf.exe
  "C:\Program Files\JetBrains\CLion 2018.1\bin\cmake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_181bf.dir\link.txt --verbose=1
  "C:\Program Files\JetBrains\CLion 2018.1\bin\cmake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_181bf.dir --manifests  -- CMAKE_LINKER-NOTFOUND /nologo @CMakeFiles\cmTC_181bf.dir\objects1.rsp  /out:cmTC_181bf.exe /implib:cmTC_181bf.lib /pdb:C:\Users\huang\Documents\Programs\grade\cmake-build-release-clang-1\CMakeFiles\CMakeTmp\cmTC_181bf.pdb /version:0.0  /machine:x64  /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib 
  RC Pass 1: command "rc /foCMakeFiles\cmTC_181bf.dir/manifest.res CMakeFiles\cmTC_181bf.dir/manifest.rc" failed (exit code 0) with the following output:
  缁崵绮洪幍鍙ョ瑝閸掔増瀵氱�规氨娈戦弬鍥︽閵嗕慷ingw32-make.exe[1]: *** [CMakeFiles\cmTC_181bf.dir\build.make:98: cmTC_181bf.exe] Error -1
  mingw32-make.exe[1]: Leaving directory 'C:/Users/huang/Documents/Programs/grade/cmake-build-release-clang-1/CMakeFiles/CMakeTmp'
  mingw32-make.exe: *** [Makefile:125: cmTC_181bf/fast] Error 2
  
  CMake will not be able to correctly generate this project.
  Call Stack (most recent call first):
  CMakeLists.txt:2 (project)
  </code></pre>
  
  <p>I guess it may be because I haven't set the target as I will do in the command line, and the default target is VC. In CLion interface, how should I do it?</p>