3

I have multiple cpp files in my workspace folder. I want to write my Tasks.json file to pick up all the cpp files in the folder to build them so that linker can link them.

I want to write a generic task.json configuration for this so that I can have multiple folder sin my workspace folder.

Is it possible?

My current Task.json file

"version": "2.0.0",
  "tasks": [

    // MAC OS Build
    {
      "type": "shell",
      "label": "MAC g++ build active file",
      "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": true,
        "panel": "shared",
        "showReuseMessage": true,
        "clear": true
      },
      "command": "/usr/bin/g++",
      "args": [
        "-Wall",
        "-Wno-c++11-extensions",
        "-std=c++14",
        "-g",
        "${file}",
        "-o",
        "${fileDirname}/${fileBasenameNoExtension}"
      ],
      "options": {
        "cwd": "/usr/bin"
      },
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "problemMatcher": {
        "owner": "cpp",
        "fileLocation": ["relative", "${workspaceFolder}"],
        "pattern": {
            "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
        }
      }
    },
aaryan6789
  • 31
  • 1
  • 2
  • 1
    If you want to compile all the cpp files in a folder called src add the following line to the args section : "${workspaceFolder}\\src\\/**.cpp", – kacie_23 Nov 19 '19 at 07:23
  • try this https://stackoverflow.com/questions/61041182/vs-code-c-compile-multiple-file/71631309#71631309 – A P Mar 26 '22 at 19:46

0 Answers0