Skip to content

Set Environement Variable In Vscode With The Cmake Plugin

Ajay Ramachandran edited this page Mar 13, 2021 · 2 revisions

Set up Cmake Kit In Vscode

First, open up your current kits using Ctrl + shift + P and "Edit User-Local Cmake Kits". Copy the data from the one you are currently using.

Create a file in the .vscode folder called cmake-kits.json and format it like below:

[{
    "name": "<name of kit>",
    "environmentVariables": {
        "<name of variable>": "1"
    },
    <DATA FROM EXISTING CMAKE KIT GOES HERE>
}]

Then, change your active kit and rebuild.

Cmake Kit button

Example Kit Config

[{
    "name": "No Logs",
    "visualStudio": "6e824f2d",
    "visualStudioArchitecture": "x64",
    "preferredGenerator": {
      "name": "Visual Studio 15 2017",
      "platform": "x64",
      "toolset": "host=x64"
    },
    "environmentVariables": {
        "USE_LOGGER": "0"
    }
},
{
    "name": "Testing - No Logs",
    "visualStudio": "6e824f2d",
    "visualStudioArchitecture": "x64",
    "preferredGenerator": {
      "name": "Visual Studio 15 2017",
      "platform": "x64",
      "toolset": "host=x64"
    },
    "environmentVariables": {
        "TESTING": "1",
        "USE_LOGGER": "0"
    }
},
{
    "name": "Testing - With Logs",
    "visualStudio": "6e824f2d",
    "visualStudioArchitecture": "x64",
    "preferredGenerator": {
      "name": "Visual Studio 15 2017",
      "platform": "x64",
      "toolset": "host=x64"
    },
    "environmentVariables": {
        "TESTING": "1"
    }
}]
Clone this wiki locally