vscode配置cmake

    技术2026-02-04  3

    1.下载cmake 2.下载ninja https://github.com/ninja-build/ninja/releases

    3.将ninja.exe放入到cmake的bin目录下 添加cmake的bin目录到环境变量 在cmd中输出cmake检查是否正确配置

    4.安装vscode插件 5.点击下方扫描工具包,选择gcc 9.2.0 6.初始化生成 ctrl+shift+p 或者点设置–命令面板

    输入CMake快速入门 然后输入新项目的名字 选择创建可执行文件 此时会自动配置 运行完后会生成build和cmakelists.txt和main.cpp 点击vscode下方的生成会在build目录下生成hello.exe 在终端中运行hello.exe 7.更改后生成 或者点击 8.

    出现问题:

    [cmakefileapi-parser] Code model version (2.1) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect. [cmakefileapi-parser] Code model version (2.1) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect. [build] Build finished with exit code 0

    解决办法:

    After running the CMake configuration, I opened this file -> "build\.cmake\api\v1\reply\codemodel-v2-ab6f9cacd31dc7acf0c6.json", scrolled all the way down, and changed the value of "minor" from 1 to 0. When I clicked Build again, the warnings were gone. FYI, I don't know if this breaks something else or not, I just figured it out by trail and error. "version" : { "major" : 2, "minor" : 0 }
    Processed: 0.019, SQL: 9