报错:
CMake Error: Generator: execution of make failed. Make command was: /usr/bin/gmake -f Makefile cmTC_f956b/fast &&
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/bin/gcc
CMake Error: Generator: execution of make failed. Make command was: /usr/bin/gmake -f Makefile cmTC_9d4d2/fast &&
-- Check for working C compiler: /usr/bin/gcc - broken
CMake Error at /usr/local/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/usr/bin/gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /workspace/CustomOp/broadcast/build_out/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_9d4d2/fast && No such file or directory
Generator: execution of make failed. Make command was: /usr/bin/gmake -f Makefile cmTC_9d4d2/fast &&
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:11 (project)
-- Configuring incomplete, errors occurred!
See also "/workspace/CustomOp/broadcast/build_out/CMakeFiles/CMakeOutput.log".
See also "/workspace/CustomOp/broadcast/build_out/CMakeFiles/CMakeError.log".
解决办法:
错误的根源是 Make command : /usr/bin/gmake cmTC_003e6/fast &&。用grep查了一下,这条语句存储在CMakeCache.txt中。如:
CMakeCache.txt:CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/gmake
是原SDK在以前的平台运行的时候留下的。而在新平台里/usr/bin/gmake和cmTC_003e6/fast 文件都没有。
解决方案:有的开发者会想到去手动更改CMakeCache.txt中的值,这是不建议的,因为未必会生效,也可能引入语法错误。
解决方案其实很简单,就是$rm所有CMakeCache。在项目重新编译的过程中,会调用cmake重新计算与运行环境相关的值。当然,用户选项如果仅在CMakeCache.txt中,而没有在项目中的其它文件中记录,需要手动添加。