使用一些选项为 CMake 配置 Visual Studio Code [英] Configure Visual Studio Code for CMake with some options
问题描述
我想使用 CMake 工具扩展 来开发 CMakeVisual Studio Code 中的项目.
我在命令行中使用以下命令构建项目:
PS projectuild>cmake -G"Visual Studio 14 2015 Win64" -DBOOST_ROOT=somepath -DQT_ROOT=anotherpathprojectpath
如何在 .vscode
文件夹下的 .cmaketools.json
文件中使用相同的选项设置相同的命令?我想从编辑器内部运行它,如果可能,还指定输出文件夹,而不是在我的项目中创建一个 build
文件夹.
这是我实际的.cmaketools.json
:
<代码>{变体":{"label": "调试",关键字设置":{"buildType": "调试"},"description": "在不执行优化的情况下发出调试信息"},活动环境":[Visual C++ 14.0 - amd64"]}
.vscode.cmaketools.json
文件只是 Visual Studio Code - CMake Tools Extension 的工作区缓存".查看他们的代码:
/*** 工作区缓存存储了方便记忆的扩展状态* 执行之间.诸如活动变体或启用的环境之类的东西* 存储在这里,以便在扩展时可以快速调用它们* 重新开始.*/
我认为你想要的是 这里 与例如以下内容:
{"cmake.generator": "Visual Studio 14 2015 Win64","cmake.configureSettings": { "BOOST_ROOT": "some/path", "QT_ROOT": "another/path" }}
I want to use the CMake Tools extension for developing a CMake project in Visual Studio Code.
I build the project in the command line with following command:
PS projectuild> cmake -G"Visual Studio 14 2015 Win64" -DBOOST_ROOT=somepath -DQT_ROOT=anotherpath projectpath
How can I set the same command with same options in the .cmaketools.json
file that I've under the .vscode
folder? I want to run it from inside the editor and, if possible, specify also the output folder instead of creating a build
folder inside my project one.
This is my actual .cmaketools.json
:
{
"variant": {
"label": "Debug",
"keywordSettings": {
"buildType": "debug"
},
"description": "Emit debug information without performing optimizations"
},
"activeEnvironments": [
"Visual C++ 14.0 - amd64"
]
}
The .vscode.cmaketools.json
file is only the "workspace cache" of Visual Studio Code - CMake Tools Extension. See their code:
/** * The workspace cache stores extension state that is convenient to remember * between executions. Things like the active variant or enabled environments * are stored here so that they may be recalled quickly upon extension * restart. */
I think what you want is a .vscodesettings.json
as described here with e.g. the following content:
{
"cmake.generator": "Visual Studio 14 2015 Win64",
"cmake.configureSettings": { "BOOST_ROOT": "some/path", "QT_ROOT": "another/path" }
}
这篇关于使用一些选项为 CMake 配置 Visual Studio Code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!