How to compile/build multiple cpp files in a folder in vscode?

Viewed 2384

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
        }
      }
    },
0 Answers
Related