Skip to content

vscode的cmaketools

约 167 字小于 1 分钟

2025-07-05

cmaketools 插件的一些问题

指定生成器

使用插件生成的 cmakepresets cmake 预设不能指定 cmake_cxx_flagcmake_c_flag 和生成器:

"generator": "Ninja"

"CMAKE_CXX_FLAGS": "--target=x86_64-windows-gnu --sysroot=D:\\workfile\\toolchain\\compiler\\x86_64-windows-gnu\\x86_64-windows-gnu -fuse-ld=lld  -rtlib=compiler-rt -unwindlib=libunwind  -lc++abi -lunwind -lntdll -Wno-unused-command-line-argument -stdlib=libc++",

"CMAKE_C_FLAGS": "--target=x86_64-windows-gnu --sysroot=D:\\workfile\\toolchain\\compiler\\x86_64-windows-gnu\\x86_64-windows-gnu -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind  -lc++abi -lunwind -lntdll -Wno-unused-command-line-argument "

配置中 Cmake: Preferred Generators 项指定生成器。

Clangd设置

Clangd: Arguments

--compile-commands-dir=${workspaceFolder}/out/build/clang_debug

注意

这个指定路径是固定的,需要生成预设的时候改这个:

"binaryDir": "${sourceDir}/out/build/${presetName}",