CMake Error at CMakeLists.txt:5 (PROJECT): The CMAKE_C_COMPILER: cl is not a full path

Error info:
– Building for NMake Makefiles
— The C compiler identification is unknown
— The CXX compiler identification is unknown
CMake Error at CMakeLists. txt:5 (PROJECT):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, c make must be run from a shell that can use the compiler cl from the command line.   This environment is unable to invoke the cl compiler.   To fix this problem, run CMake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable “CC” or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.

CMake Error at CMakeLists. txt:5 (PROJECT):
The CMAKE_CXX_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, c make must be run from a shell that can use the compiler cl from the command line.   This environment is unable to invoke the cl compiler.   To fix this problem, run c make from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable “CXX” or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.

— Configuring incomplete, errors occurred!
See also “E:/gc/c_test1/build/CMakeFiles/CMakeOutput.log”.
See also “E:/gc/c_test1/build/CMakeFiles/CMakeError.log”.

How to Fix
1.Don’t use make.. Use  these  commands:

cmake -G "MSYS Makefiles" ..

2. If the first one doesn’t work, set the path:

$ export CC=/c/MinGW/bin/gcc.exe
$ export CXX=/c/MinGW/bin/g++.exe
$ cmake -G "MinGW Makefiles" ..
-- The CXX compiler identification is GNU 4.8.1        
...
$ mingw32-make

The second:

$ cmake -DCMAKE_C_COMPILER=/c/MinGW/bin/gcc.exe -DCMAKE_CXX_COMPILER=/c/MinGW/bin/g++.exe ..

If not, please refer to the following link:
https://www.e-learn.cn/content/wangluowenzhang/22835
https://stackoverflow.com/questions/29746950/cmake-cannot-find-compiler


Read More: