title: how can I tie together the C/C++ configurations in VSCode with the tasks and launch configurations?
body: <p>In general, projects have several build flavors (especially for development) like Debug and Release, and some projects also allow cross-platform configurations. Visual Studio calls that "platform" (Win32/x&amp;4...) and "configuration" for instance, and in QtCreator it's a combination of Kit (toolchain) and Configuration (debug/release), while the VSCode C++ extension calls this Configuration.</p>
  
  <p>My issue is that while it is possible to query the currently selected configuration through a command, I can't find a way to use configuration-specific variables in the tasks.json or launch.json file. I can only query the configuration name.</p>
  
  <p>As an example, this is a sample C/C++ properties files:</p>
  
  <pre class="lang-json prettyprint-override"><code>{
      "configurations": [
          {
              "name": "linux_gnu_amd64-clang_amd64-10.0.0:debug",
              "compileCommands": "${workspaceFolder}/.vscode/linux_gnu_amd64-clang_amd64-10.0.0/debug/compile_commands.json",
              "intelliSenseMode": "clang-x64",
              "cStandard": "c11",
              "cppStandard": "c++17"
          },
          {
              "name": "linux_gnu_amd64-clang_amd64-10.0.0:final",
              "compileCommands": "${workspaceFolder}/.vscode/linux_gnu_amd64-clang_amd64-10.0.0/final/compile_commands.json",
              "intelliSenseMode": "clang-x64",
              "cStandard": "c11",
              "cppStandard": "c++17"
          },
          {
              "name": "linux_gnu_amd64-clang_amd64-11.0.0:debug",
              "compileCommands": "${workspaceFolder}/.vscode/linux_gnu_amd64-clang_amd64-11.0.0/debug/compile_commands.json",
              "intelliSenseMode": "clang-x64",
              "cStandard": "c11",
              "cppStandard": "c++17"
          },
          {
              "name": "linux_gnu_amd64-clang_amd64-11.0.0:final",
              "compileCommands": "${workspaceFolder}/.vscode/linux_gnu_amd64-clang_amd64-11.0.0/final/compile_commands.json",
              "intelliSenseMode": "clang-x64",
              "cStandard": "c11",
              "cppStandard": "c++17"
          }
      ]
  }
  </code></pre>
  
  <p>This allows me to choose between the configurations and get perfect code completion. For building, I can depend on the configuration name:</p>
  
  <pre class="lang-json prettyprint-override"><code>{
    "tasks": [
      {
        "label": "build",
        "type": "process",
        "command": ["/usr/bin/python3"],
        "args": ["waf", "--tests", "build:${command:cpptools.activeConfigName}"],
        "group": {
          "kind": "build",
          "isDefault": true
        }
      }
    ]
  }
  </code></pre>
  
  <p>So whenever I type <code>Ctrl+Shift+B</code> it will automatically build the current configuration, since the task will pass the current configuration to the build system. For that, the configuration HAS to match the build system's configuration name though.</p>
  
  <p>Unfortunately, communication seems to stop there; especially when I want to add a debug target:</p>
  
  <pre class="lang-json prettyprint-override"><code>{
      "configurations": [
          {
              "name": "(gdb) Launch",
              "type": "cppdbg",
              "request": "launch",
              "program": "???? configuration dependent path",
              "args": [],
              "stopAtEntry": false,
              "cwd": "${workspaceFolder}",
              "MIMode": "gdb (actually also configuration dependent)",
          }
      ]
  }
  </code></pre>
  
  <p>I can't seem to be able to retrieve the executable name from the configuration in any way; I have noticed one can add host-specific configurations in the launch.json file (linux, osx, windows) but what I'd need is actually <em>target</em>-specific sections.</p>
  
  <p>Is there any other way that I overlooked? all other tools I use make debugging (and building) variables somehow dependent on the currently selected configuration. I could of course add many launch configurations but that would not be very user friendly (there could be a mismatch between the currently selected configuration and the launch configuration for instance)</p>
  
  <p>Ideally, the launch configuration would look something like this:</p>
  
  <pre class="lang-json prettyprint-override"><code>{
      "configurations": [
          {
              "type": "cppdbg",
              "request": "launch",
              "program": "${cpptools.currentConfiguration.OutputName}",
          }
      ]
  }
  </code></pre>
  
  <p>or:</p>
  
  <pre class="lang-json prettyprint-override"><code>{
      "configurations": [
          {
              "type": "cppdbg",
              "request": "launch",
              "linux_gnu_amd64-clang_amd64-10.0.0:debug": {
                "program": "path/to/clang10/debug/exe"
              },
              "linux_gnu_amd64-clang_amd64-10.0.0:final": {
                "program": "path/to/clang10/final/exe"
              },
              "linux_gnu_amd64-clang_amd64-11.0.0:debug": {
                "program": "path/to/clang11/debug/exe"
              },
              "linux_gnu_amd64-clang_amd64-11.0.0:final": {
                "program": "path/to/clang11/final/exe"
              },
          }
      ]
  }
  </code></pre>