# Libraries and Native Visualization Files (.natvis)

**URL:** https://discourse.cmake.org/t/libraries-and-native-visualization-files-natvis/8069
**Category:** Usage
**Created:** [May 6, 2023, 4:34pm UTC](https://discourse.cmake.org/t/libraries-and-native-visualization-files-natvis/8069 "2023-05-06T16:34:33Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![buildSystemPerson](https://discourse.cmake.org/user_avatar/discourse.cmake.org/buildsystemperson/32/2851_2.png) [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)
#### Post date: [May 6, 2023, 4:34pm UTC](https://discourse.cmake.org/t/libraries-and-native-visualization-files-natvis/8069/1 "2023-05-06T16:34:33Z")

</div>

I have a header only library that provides a [natvis file](https://learn.microsoft.com/en-us/cpp/build/reference/natvis-add-natvis-to-pdb?view=msvc-170) to users. This is useful to users of my library on MSVC in particular. Since it provides a friendlier debugging interface for custom containers.

If I was shipping a SHARED or MODULE type library this would be easy since I could just use the appropriate link command for the MSVC compiler.

```cmake
target_link_options(foobar PRIVATE 
    /NATVIS:${CMAKE_CURRENT_LIST_DIR}/foobar.natvis
)

```

However, this gets complicated for STATIC / HEADER only libraries. I also want it to work with both Ninja and the Visual Studio generator. I also want it to work cleanly with my library being absorbed via `add_subdirectory` or `find_package`.

What is the best way to support `natvis` files cleanly in CMake?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 8, 2023, 6:35pm UTC](https://discourse.cmake.org/t/libraries-and-native-visualization-files-natvis/8069/2 "2023-05-08T18:35:19Z")

</div>

CMake probably needs to learn NatVis support itself. [https://gitlab.kitware.com/cmake/cmake/-/issues/16874](https://gitlab.kitware.com/cmake/cmake/-/issues/16874)
