使用某些选项为{CM 44配置Visual Studio代码

时间:2017-02-23 18:31:30

标签: cmake visual-studio-code

我想使用CMake Tools extension在Visual Studio Code中开发CMake项目。

我使用以下命令在命令行中构建项目:

PS project\build> cmake -G"Visual Studio 14 2015 Win64" -DBOOST_ROOT=some\path -DQT_ROOT=another\path\ project\path

如何在.cmaketools.json文件夹下的.vscode文件中使用相同的选项设置相同的命令?我想在编辑器中运行它,如果可能的话,还要指定输出文件夹,而不是在我的项目中创建一个build文件夹。

这是我的实际.cmaketools.json

{
  "variant": {
    "label": "Debug",
    "keywordSettings": {
      "buildType": "debug"
    },
    "description": "Emit debug information without performing optimizations"
  },
  "activeEnvironments": [
    "Visual C++ 14.0 - amd64"
  ]
}

1 个答案:

答案 0 :(得分:4)

.vscode\.cmaketools.json文件只是"工作区缓存" Visual Studio代码 - CMake工具扩展。查看他们的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所描述的here,例如以下内容:

{
    "cmake.generator": "Visual Studio 14 2015 Win64",
    "cmake.configureSettings": { "BOOST_ROOT": "some/path", "QT_ROOT": "another/path" }
}