在VS2019中CMake生成出现报错

简介: 在VS2019中CMake生成出现报错

问题

严重性代码说明项目文件行禁止显示状态
错误    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编译,那么可能会比较麻烦,下面是一个比较详细的链接。

另外一种处理方式

相关文章
|
9天前
|
存储 自然语言处理 Linux
CMake基础(1)初识CMake
CMake基础(1)初识CMake
19 0
|
9月前
|
C++
CMake中使用vcpkg
vcpkg是一个微软开源的C++包管理器。 在以前的开发中,如果在项目中需要使用某个开源库,例如qt,我们需要取官网下载qt的源码,然后构建得到对应的库,然后在项目中链接这个库。对于自己熟悉的库还好说,若是不熟悉的库,如何拉取源码?如何构建?如何在项目中引用?等等这些问题通常会困扰我们,然而,大多数情况下,我们只是使用这个开源库,并不需要关心这个库的构建和编译等问题。如此,在以前的开发过程中,往往会花费不少的时间在引入开源库上。 vcpkg是在背景下开发出来的,通过vcpkg,我们可以在项目中很方便的引入开源库,不用再关心拉取代码、构建开源库的这些事情。 CMake构建的项目中引入开源库
114 0
|
Linux 异构计算
|
C++
cmake安装与使用
cmake安装与使用
264 0
cmake安装与使用
|
Ubuntu
CMake
CMake
108 0
|
消息中间件 关系型数据库 C语言
|
Linux 前端开发 关系型数据库
|
Java Linux C语言
|
C语言
CMake的使用
使其生效的方法:首先cmake生成makefile,然后make edit_cache编辑编译选项;Linux下会打开一个文本框,可以更改,该完后再make生成目标文件——emacs不支持make edit_cache
1219 0