First time to use cmake in Win7 64bit. The MinGW compiler is installed.
(1) Configure top CMakeLists.txt as below to point to MinGW compiler.
cmake_minimum_required(VERSION 2.6)
project(CMAKEDEMO)
set(CMAKE_C_COMPILER "mingw32-gcc")
set(CMAKE_CXX_COMPILER "mingw32-g++")
set(CMAKE_CXX_FLAGS "-g -Wall")
add_subdirectory(w01-cpp)
(2) Create a build dir, enter to the build dir and issue 'cmake -G "MinGW Makefiles" ..', encounter following error which complained the sh.exe is in the path.
CMake Error at c:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeMinGWFindMake.cmake:20 (MESSAGE):
sh.exe was found in your PATH, here:
c:/Program Files (x86)/Git/bin/sh.exe
For MinGW make to work correctly sh.exe must NOT be in your path.
Run cmake from a shell that does not have sh.exe in your PATH.
If you want to use a UNIX shell, then use MSYS Makefiles.
...
(3) That is not good, I need Git. I try 'cmake -G "MSYS Makefiles" ..' and then "make", it worked.
(4) I also tried to rename my sh.exe to shxx.exe, and then issue 'cmake -G "MSYS Makefiles" ..' again, then issue 'mingw32-make', also worked.
Reference:
http://www.cnblogs.com/ode/archive/2011/08/03/2147089.html