vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

CMake: Build Target from tasks.json to support compound debugging

Open timo-suoranta-varjo opened this issue 5 years ago • 5 comments

  • I want to debug multiple individual executables together (server, client) that have no build time dependencies.
  • I have compounds in launch.json that works for this.
  • For each executable in my compound, I'd like to have preLaunchTask in launch.json to make sure those executables are rebuilt before debugging.
  • In the preLaunchTasks I would like to be able to perform CMake: Build Target, so that I can build those targets.

There does not seem to be a way to perform CMake: Build Target from a task in tasks.json. Is there a way? Or does this need a new feature in CMake Tools? Thanks!

timo-suoranta-varjo avatar Dec 17 '20 08:12 timo-suoranta-varjo

Thank you for suggesting this feature idea. Currently, the command "CMake: Build Target" can't be hooked up to tasks.json, only "CMake: Build" (which builds the default target if defined or ALL otherwise). You could use this one for now, even if this would cause the rebuild of targets that you don't need.

andreeis avatar Dec 18 '20 21:12 andreeis

Building all is not always an option. Building all of a large project can take a really long time. Some targets might not build at all, because the project has not yet been fully ported to a new environment.

I worked around this by using shell command cmake --build .. --config .. --target .. -- -j .. in tasks.json, essentially copying what CMake: Build Target outputs when it executes. But I need to copy paste an entry for every target.

timo-suoranta-varjo avatar Dec 19 '20 07:12 timo-suoranta-varjo

This issue is now marked as 'stale-old' due to there being no activity on it for the past 720 days. Unless the 'stale-old' label is removed or the issue is commented on, this will be remain open for at least 14 days and then it may be closed. If you would like to make this issue exempt from getting stale, please add the 'stale-exempt' label.

github-actions[bot] avatar Oct 19 '23 16:10 github-actions[bot]

Yes, please make this work:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cmake",
            "label": "CMake: build",
            "command": "build",
            "targets": [
                "${command:cmake.launchTarget}"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": [],
            "detail": "CMake template build task"
        }
    ],
}

It should be as easy as just making the target name available (instead of the full path).

MartyMcFlyInTheSky avatar Feb 28 '24 14:02 MartyMcFlyInTheSky

I am also running in this issue, would love to use the build target from tasks

nickyvanurk avatar Sep 10 '25 17:09 nickyvanurk