问题
严重性代码说明项目文件行禁止显示状态
错误 CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx86/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: E:/Open_souce_project/cmake-examples-master/01-basic/B-hello-headers/out/build/x64-Debug (默认值)/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_1c316 && [1/2] Building C object CMakeFiles\cmTC_1c316.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_1c316.exe
FAILED: cmTC_1c316.exe
cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_1c316.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1428~1.293\bin\Hostx86\x64\link.exe /nologo CMakeFiles\cmTC_1c316.dir\testCCompiler.c.obj /out:cmTC_1c316.exe /implib:cmTC_1c316.lib /pdb:cmTC_1c316.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
RC Pass 1: command "rc /fo CMakeFiles\cmTC_1c316.dir/manifest.res CMakeFiles\cmTC_1c316.dir/manifest.rc" failed (exit code 0) with the following output:
系统找不到指定的文件。
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project. C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake 66
解决办法一:
在vs中,项目->CMake设置
最下面有个显示高级
将Ninja改成Unix Makefiles就可以避开这个问题了。
一般改成unix Makefiles就能直接用了。
解决办法二:
如果执意要选用Ninja编译,那么可能会比较麻烦,下面是一个比较详细的链接。文章来源:https://www.toymoban.com/news/detail-532685.html
另外一种处理方式文章来源地址https://www.toymoban.com/news/detail-532685.html
到了这里,关于在VS2019中CMake生成出现报错的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!