question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using command variables in task with CMake Tools

See original GitHub issue

Brief Issue Summary

Tried to use this in tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "CMake Build",
            "command": "${command:cmake.build}",
            "type": "shell",
            "group": "build",
            "problemMatcher": []
        }
    ]
}

Or

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "CMake Build All",
            "command": "${command:cmake.buildAll}",
            "type": "shell",
            "group": "build",
            "problemMatcher": []
        }
    ]
}

Expected:

CMake Tools to build project as when running “CMake: Build” or “CMake: BuildAll” command from command palette.

Apparent Behavior:

Got error: For “CMake Build”:

[rollbar] Unhandled exception: Unhandled Promise rejection: build TypeError: Cannot read property 'fsPath' of undefined {}

For “CMake Build All”:

[rollbar] Unhandled exception: Unhandled Promise rejection: buildAll TypeError: str.replace is not a function {}

After “CMake Build All” task CMake tools becomes broken, and even from CMake side panel gives an error:

A CMake task is already running. Stop it before trying to build.

Platform and Versions

  • Operating System: Linux Mint 19
  • CMake Version: 3.5.1
  • VSCode Version: 1.38.1
  • CMake Tools Extension Version: 1.3.1
  • Compiler/Toolchain: arm-none-eabi-gcc 4.8

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

7reactions
andreeiscommented, Nov 10, 2020

I think the example at the beginning of the issue (which you used) is the old way of attempting to do this. Try to apply the below changes to your example and let us know how that works: “command”: “build”, “type”: “cmake”,

2reactions
stlkrcommented, May 16, 2020

Also, if(or when) command variable feature becomes working, it would be nice to publish the command IDs for CMake Tools somewhere in documentation. Because I wasn’t able to find it anywhere except CMake Tools’s sources.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring CMake Tools - vector Of bool
Configuring CMake Tools¶. CMake Tools supports a variety of settings that can be set at the user or workspace level via VSCode's settings.json...
Read more >
Custom Commands — Mastering CMake
CMake supports these additional tasks using the add_custom_command and ... lists many variables that are useful for custom commands that need to reference ......
Read more >
Get started with CMake Tools on Linux - Visual Studio Code
In this tutorial, you'll use the CMake Tools extension for Visual Studio Code to ... Open a Terminal window and enter the following...
Read more >
CMake@1 - CMake v1 task | Microsoft Learn
In this article. Syntax; Inputs; Output variables; Remarks; Requirements. Use this task to build with the CMake cross-platform build system.
Read more >
How to run Cmake in Visual Studio Code using tasks
{ "label": "cmake", "type": "shell", "options": { "cwd": "${workspaceRoot}/build" }, "command": "cmake \"MinGW Makefiles\" ${workspaceRoot}" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found