# Does adding \`.natvis\` files via target\_sources work on Ninja?

**URL:** https://discourse.cmake.org/t/does-adding-natvis-files-via-target-sources-work-on-ninja/7316
**Category:** Usage
**Tags:** os:windows, gen:ninja
**Created:** [January 24, 2023, 11:45pm UTC](https://discourse.cmake.org/t/does-adding-natvis-files-via-target-sources-work-on-ninja/7316 "2023-01-24T23:45:56Z")
**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: [January 24, 2023, 11:45pm UTC](https://discourse.cmake.org/t/does-adding-natvis-files-via-target-sources-work-on-ninja/7316/1 "2023-01-24T23:45:56Z")

</div>

According to the docs as of CMake 3.7

> [Visual Studio Generators](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#visual-studio-generators) for VS 2010 and above learned to place `.natvis` source files into VS project files properly.

Which means the following will work correctly with Visual Studio generators.

```auto
target_sources(foobar PRIVATE foobar.natvis)

```

Will this also work for Ninja on MSVC?

Do I need to guard this with a check for MSVC?

---

<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: [January 26, 2023, 2:17pm UTC](https://discourse.cmake.org/t/does-adding-natvis-files-via-target-sources-work-on-ninja/7316/2 "2023-01-26T14:17:24Z")

</div>

Looking at the code, CMake literally only knows how to tell VS “this is a natvis file”. The IDE then takes that indication to do what is necessary; no other generator knows about it and will just ignore the file.
