环境
CLion+Cmake+Mingw
报错日志
-- 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.
如果是CPP项目,可能还会报
-- The CXX compiler identification is unknown
原因
cmake因未知原因无法check c compiler的id,导致编译无法进行
解决方法
在CMakeLists.txt文件中添加以下配置强制指定compiler的id
INCLUDE(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER(gcc GNU)
CMAKE_FORCE_CXX_COMPILER(g++ GNU)
添加后重新运行cmake指令即可