Setting VS_DEBUGGER_ENVIRONMENT for Ninja Multi-Config

We have cmake code like

  set_target_properties(${PROJECT_NAME} PROPERTIES
                        VS_DEBUGGER_ENVIRONMENT "PATH=%PATH%;${VS_DEBUGGER_PATHS}")

But when I have Visual Studio 17.8.4 Configure the project folder (though using a CMakeUserPresets.json file), the build is just fine, but when I try to debug the executing I get the dreaded “couldn’t load XXXX.dll” errors. This is because those dependent libraries are in their own installation locations (vcpkg location). For pure Visual Studio generators we used the above and it solved the problem. But now when I have Visual Studio open the folder and use a CMake preset it looks like there isn’t any way to set those paths.

Has anyone experienced this? Does anyone have any thoughts?

Thank You

This should be covered by this article: Configure CMake debugging sessions in Visual Studio | Microsoft Learn

It can be set using the env keyword in a launch.vs.json file. However, there do not seem to be a way to use any variables from the the CMake Configuration phase. Thus forcing you to use hardcoded environments paths in your launch.vs.json file.

See: launch.vs.json

Can’t you use configure_file() to achieve this? Or does it have to be in the source directory?

launch.vs.json is placed by Visual Studio in a hidden folder called .vs in the root folder of your codebase. Since CMakeProject folder builds in Visual Studio uses in-source builds by default it should be possible to use a configure_file() approach to generate a launch.vs.json file. But that seems like a really ugly workaround IMHO.