microsoft / microsoft/vscode-cmake-tools
The default value for cmake.buildTargetName is not a valid build target name
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
### Brief Issue Summary
It seems impossible to create a task that will build the current target, including when a current target has not been explicitly selected. It would be convenient to have this as the default build task, such that by default it does the same as `cmake: Build`, but one can also select a different target and subsequent builds would be scoped to that target.
```json
{
"type": "cmake",
"label": "Build Selected Target",
"command": "build",
"targets": ["${command:cmake.buildTargetName}"],
"problemMatcher": "$blah",
"group": {
"kind": "build",
"isDefault": true
}
},
```
When invoking this task without having selected a build target in the CMake pane, it attempts to execute the `[Targets in Preset]` target, which is invalid, and fails. It would be more convenient for this value to default to `all`.
### CMake Tools Diagnostics
```shell
{
"os": "win32",
"vscodeVersion": "1.87.0",
"cmtVersion": "1.17.17",
"configurations": [
{
"folder": ",
"cmakeVersion": "3.28.20240123",
"configured": true,
"generator": "Ninja",
"usesPresets": true,
"compilers": {
"C": "clang",
"CXX": "clang"
}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Debug"
],
"requests": [],
"responses": [],
"partialMatches": [],
"targetCount": 252,
"executablesCount": 6,
"librariesCount": 215,
"targets": []
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "always",
"configureOnOpen": true
}
]
}
```
```
### Debug Log
```shell
* Executing task: Build Selected Target
build task started....
"C:\Program Files\CMake\bin\cmake.EXE" --build --target "[Targets In Preset]"
ninja: error: unknown target '[Targets In Preset]'
build finished with error(s).
* The terminal process failed to launch (exit code: 1).
* Terminal will be reused by tasks, press any key to close it.
```
### Additional Information
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the implementation of the cmake.buildTargetName setting and the task target expansion used for CMake build tasks. Reproduce the task without a selected target, then verify that its default resolves to a valid target such as all and that selecting a target still scopes later builds to it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, typescript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100