skip to Main Content

This is not about Visual Studio Code. It’s not about launch.json. This question is about Visual Studio and its launch.vs.json file.

In VS 2022’s launch.vs.json file, in a custom debug target, how can I reference the current CMake build type? I need something like this:

{
  "version": "0.2.1",
  "defaults": {},
  "configurations": [
    {
      "type": "default",
      "project": "CMakeLists.txt",
      "projectTarget": "MyProgram.exe (app\MyProgram\MyProgram.exe)",
      "name": "MyProgram.exe (app\MyProgram\MyProgram.exe)",
      "environment": [
        {
          "name": "PATH",
          "value": "D:\my-dlls-for-build-type-${cmake.buildType}"
        }
      ]
    }
  ]
}

But ${cmake.buildType} is not recognized here. I get this error: Var:${cmake.buildType} failed evaluation.

2

Answers


  1. Take a look of this:

    Reference keys in CMakeSettings.json

    From the official document:

    Environment variables defined in CMakeSettings.json can also be used
    in launch.vs.json using the syntax ${env.VARIABLE_NAME}.

    Is this what you want?

    Login or Signup to reply.
  2. Use ${cmake.configurationType}.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search