microsoft / microsoft/vscode-cmake-tools

[Bug] Debug command also builds the build target

Open
#4,445 7 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

### Brief Issue Summary

When using the "Launch/Debug" functionality to launch the selected "Launch/Debug" target, it used to only build and launch that specific target. In a recent update, it seems the CMake extension now also builds the selected "Build" target.

### CMake Tools Diagnostics

```shell
{
"os": "darwin",
"vscodeVersion": "1.99.3",
"cmtVersion": "1.20.53",
"configurations": [
{
"folder": "/Users/chammard/Work/fp/fprime",
"cmakeVersion": "3.31.5",
"configured": true,
"generator": "Unix Makefiles",
"usesPresets": true,
"compilers": {
"C": "/Library/Developer/CommandLineTools/usr/bin/cc",
"CXX": "/Library/Developer/CommandLineTools/usr/bin/c++"
}
},
{
"folder": "/Users/chammard/Work/fp/fprime",
"cmakeVersion": "3.31.5",
"configured": true,
"generator": "Unix Makefiles",
"usesPresets": true,
"compilers": {
"C": "/Library/Developer/CommandLineTools/usr/bin/cc",
"CXX": "/Library/Developer/CommandLineTools/usr/bin/c++"
}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Debug"
],
"requests": [],
"responses": [],
"partialMatches": [],
"targetCount": 347,
"executablesCount": 86,
"librariesCount": 150,
"targets": []
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": false
},
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": false
}
]
}
```

### Debug Log

```shell
Executing command: /opt/homebrew/bin/cmake --build /path/to/build --parallel 16 --target --
....
```

### Additional Information

When using the "Launch/Debug" functionality to launch the selected "Launch/Debug" target, it used to only build and launch that specific target. In a recent update, it seems the CMake extension now also builds the selected "Build" target. This is annoying because it is very convenient to only select a specific target on Launch/Debug, and build only that one. Now it will also build a second target if the selected Build target is not the same as the Launch/Debug one.

Or am I dreaming this change and my configuration got messed up somehow?

From the CMake logs, when I use the `CMake: Debug` command, I get the following:

```
Executing command: /opt/homebrew/bin/cmake --build /path/to/build --parallel 16 --target --
```

It should only build the ``, but it also builds ``

Contributor guide

Open the contributing guide

Research direction

Start from the CMake: Debug command and the logged `cmake --build` invocation, especially how the selected Build and Launch/Debug targets are combined. Trace the command construction and verify that debugging builds only the selected Launch/Debug target, then reproduce with differing targets to confirm the fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, typescript
Domain
build-system, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.