The C compiler identification is unknown

The environment
CLion+Cmake+Mingw
An error log

-- The C compiler identification is unknown
-- Check for working C compiler: D:/MinGW/bin/gcc.exe
-- Check for working C compiler: D:/MinGW/bin/gcc.exe -- broken
CMake Error at D:/Program Files/JetBrains/CLion 2019.2.3/bin/cmake/win/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler

    "D:/MinGW/bin/gcc.exe"

  is not able to compile a simple test program.

If it is a CPP program, it may be reported again

-- The CXX compiler identification is unknown

why
CMAKE could not check the C Compiler ID for unknown reasons, causing compilation to fail
The solution
Add the following configuration to the cMakelists.txt file to force the Compiler ID to be specified

INCLUDE(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER(gcc GNU)
CMAKE_FORCE_CXX_COMPILER(g++ GNU)

Rerun the cmake directive after adding it

Read More: