vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

Run and `Debug` and `Run without debugging` didn't respect `environment` from build preset

Open asergunov opened this issue 3 years ago • 1 comments

Brief Issue Summary

I have a library dependency which has same dll names for debug and release builds, but has different folder. So I need to have build configuration - dependent item in PATH.

It looks like it's not possible in v1.11.26.

Currently I have launch.json with ${input:configuration} so user can select which version to debug/run.

Native solution is to add it to CMakePresets.json. It supports environment for configuration and build presets. But looks like plugin doesn't respect environment from build preset, only from configuration.

CMakePresets.json

{
    "version": 3,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 21,
        "patch": 0
    },
    "configurePresets": [
        {
            "name": "default"
            "environemnt": {"var1": "value1", "var2": "$env{configuration}"}
        }
    ],
    "buildPresets": [
        {
            "name": "Debug",
            "configurePreset": "default",
            "configuration": "Debug",
            "environemnt": {"configuration": "Debug"}
        },
        {
            "name": "Release",
            "configurePreset": "default",
            "configuration": "Realase"
            "environemnt": {"configuration": "Release"}
        }
   ]

With that file I'd expect to have

  • var1=value1
  • var2=Debug or var2=Release
  • configuration=Debug or configuration=Release

But when I start debug or just run it using cmake plugin I have only

  • var1=value1

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response

asergunov avatar Aug 10 '22 07:08 asergunov

What exactly are you trying to do here? It looks like you are trying to use a multi-config generator, In order to have two different values, you will have to define two different configure presets, because a multi-config generator will generate all the configurations at once. Because configure happens before build, any variable you define on buildpreset, won't be available during configuration.

elahehrashedi avatar Aug 10 '22 18:08 elahehrashedi

This issue has been closed automatically because it's labeled as a 'question' and has not had recent activity.

github-actions[bot] avatar Oct 10 '22 11:10 github-actions[bot]