使用某些选项为CMake配置Visual Studio代码 [英] Configure Visual Studio Code for CMake with some options
问题描述
我想使用 CMake工具扩展来开发一个Visual Studio Code中的CMake项目。
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 project\build> cmake -G"Visual Studio 14 2015 Win64" -DBOOST_ROOT=some\path -DQT_ROOT=another\path\ project\path
如何在 .cmaketools.json
文件中使用相同的选项设置相同的命令> .vscode 文件夹?我想从编辑器内部运行它,如果可能的话,还要指定输出文件夹,而不是在我的项目一个内部创建 build
文件夹。
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.
这是我实际的 .cmaketools.json
:
{
"variant": {
"label": "Debug",
"keywordSettings": {
"buildType": "debug"
},
"description": "Emit debug information without performing optimizations"
},
"activeEnvironments": [
"Visual C++ 14.0 - amd64"
]
}
推荐答案
.vscode\.cmaketools.json
文件只是Visual Studio代码-CMake工具扩展的工作区缓存。参见他们的代码:
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.
*/
我认为您想要的是 .vscode\settings.json
,如此处,例如以下内容:
I think what you want is a .vscode\settings.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代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!