【发布时间】:2020-01-11 21:22:34
【问题描述】:
我正在创建一个 C++ 项目,使用 Visual Studio Code 作为我的 IDE,cmake 作为我的构建工具链。使用“官方”CMake Tools,我可以进行“in-tree”编译:
myComplexProjectName/
include/
src/
build/ <--Created by CMake
但是,我想像这样进行树外编译:
~/Documents/
Projets/
...
myComplexProjectName/
builds/
myComplexProjectName/
~/Documents/builds/ 文件夹已存在。
我正在尝试使用 Visual Studio Code 的任务来实现此配置。我尝试了以下tasks.json 配置:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build Cpp CAN Parser static library",
"type": "shell",
"command": "cmake",
"args": [
"${workspaceFolder}"
],
"options": {
"cwd": "~/Documents/builds/${workspaceFolderBasename}/"
},
"group": "build",
"presentation": {
// Reveal the output only if unrecognized errors occur.
"reveal": "silent"
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": "$gcc"
}
]
}
我得到以下错误:
> Executing task: cmake /home/<username>/Documents/Projets/CAN/myComplexProjectName <
The terminal shell CWD "/home/<username>/Documents/Projets/CAN/myComplexProjectName/~/Documents/builds/myComplexProjectName/" does not exist
显然我可以自己创建输出文件夹,但有没有办法可以在任务运行之前自动创建文件夹?
【问题讨论】: