title: how to get cmake to use the gnu stack of tools under msys2 (mingw)
body: <p>On Windows 10, with an installed msys2, which is a variant of mingw, I have an installed cmake with the gcc toolchain and all the standard tools like make.</p>
  
  <p>The version of g++ is 6.2 and make is 4.2.1  Both are in the path.</p>
  
  <p>When I build using cmake:</p>
  
  <pre><code>cmake .
  </code></pre>
  
  <p>it tries to build using nmake and cl.  So somehow because I am on windows cmake is trying to use the visual studio toolchain.</p>
  
  <pre><code>export CMAKE_CXX_COMPILER=g++
  </code></pre>
  
  <p>does not help.  The error is:</p>
  
  <pre><code>-- Building for: NMake Makefiles
  -- The C compiler identification is unknown
  -- The CXX compiler identification is Clang 3.8.0
  -- Check for working C compiler: D:/msys64/mingw64/bin/clang++.exe
  CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_87e5f\fast"
  -- Check for working C compiler: D:/msys64/mingw64/bin/clang++.exe -- broken
  CMake Error at D:/msys64/mingw64/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake:61 (message):
    The C compiler "D:/msys64/mingw64/bin/clang++.exe" is not able to compile a
    simple test program.
  
    It fails with the following output:
  
     Change Dir: D:/git/CSP/CMakeFiles/CMakeTmp
  
  
  
    Run Build Command:"nmake" "/NOLOGO" "cmTC_87e5f\fast"
  
  
  
    Generator: execution of make failed.  Make command was: "nmake" "/NOLOGO"
    "cmTC_87e5f\fast"
  
  
  
  
  
    CMake will not be able to correctly generate this project.
  Call Stack (most recent call first):
    CMakeLists.txt:2 (project)
  
  
  -- Configuring incomplete, errors occurred!
  See also "D:/git/CSP/CMakeFiles/CMakeOutput.log".
  See also "D:/git/CSP/CMakeFiles/CMakeError.log".
  </code></pre>