Visual Studio .natvis visualizers on imported targets
I'm running into some issues using Visual Studio's .natvis
visualisers with header-only libraries defined as INTERFACE IMPORTED
library targets.
I'm currently adding the visualiser files as INTERFACE
source files on the library target. This propagates them into all dependent targets. This enables the visualisation in the VS debugger, but has two unfortunate consequences:
- The
.natvis
files are listed as source files on each dependent project. It's especially troublesome when there are many visualisers coming from different imported libraries. I also tried usingsource_group
to at least place them under a filter, to no avail. Perhaps it does not work for propagated source files. - When the same
.natvis
file is listed as a source file on multiple targets, the VS debugger will continuously complain about multiple definitions of each visualiser. You might argue that this is a Visual Studio issue, but in truth the same.natvis
will really shouldn't be listed as a source file of multiple dependent targets in the first place.
One potential solution to this is listing the visualisers for imported dependencies as solution level files. However, from what I could tell, there is currently no way to specify solution level files.