# Setting VS\_DEBUGGER\_ENVIRONMENT for Ninja Multi-Config

**URL:** <https://discourse.cmake.org/t/setting-vs-debugger-environment-for-ninja-multi-config/9831>\
**Category:** Code\
**Created:** [January 11, 2024, 7:26pm UTC](https://discourse.cmake.org/t/setting-vs-debugger-environment-for-ninja-multi-config/9831 "2024-01-11T19:26:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![imikejackson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/imikejackson/32/301_2.png) [@imikejackson](https://discourse.cmake.org/u/imikejackson)\
**Post date:** [January 11, 2024, 7:26pm UTC](https://discourse.cmake.org/t/setting-vs-debugger-environment-for-ninja-multi-config/9831/1 "2024-01-11T19:26:54Z")

</div>

We have cmake code like

```auto
  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

---

<div class="post-metadata">

**Author:** ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)\
**Post date:** [January 11, 2024, 10:19pm UTC](https://discourse.cmake.org/t/setting-vs-debugger-environment-for-ninja-multi-config/9831/2 "2024-01-11T22:19:18Z")

</div>

This should be covered by this article: [Configure CMake debugging sessions in Visual Studio | Microsoft Learn](https://learn.microsoft.com/en-us/cpp/build/configure-cmake-debugging-sessions?view=msvc-170)

---

<div class="post-metadata">

**Author:** ![bjornblissing](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bjornblissing/32/896_2.png) [@bjornblissing](https://discourse.cmake.org/u/bjornblissing)\
**Post date:** [January 16, 2024, 12:26pm UTC](https://discourse.cmake.org/t/setting-vs-debugger-environment-for-ninja-multi-config/9831/3 "2024-01-16T12:26:26Z")

</div>

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](https://discourse.cmake.org/t/launch-vs-json/5413/1)

---

<div class="post-metadata">

**Author:** ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)\
**Post date:** [January 16, 2024, 6:28pm UTC](https://discourse.cmake.org/t/setting-vs-debugger-environment-for-ninja-multi-config/9831/4 "2024-01-16T18:28:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bjornblissing](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bjornblissing/32/896_2.png) [@bjornblissing](https://discourse.cmake.org/u/bjornblissing)\
**Post date:** [January 17, 2024, 9:20am UTC](https://discourse.cmake.org/t/setting-vs-debugger-environment-for-ninja-multi-config/9831/5 "2024-01-17T09:20:17Z")

</div>

`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.
