Skip to content

Commit 8da6c3b

Browse files
committed
ENH: Add Visual Studio specific debug helpers to ITKCommon project
Starting in Visual Studio 2022 version 17.6, copying these files to VS installation directory will no longer be required. Natvis has been supported for longer, including all currently supported Visual Studio versions.
1 parent efe5933 commit 8da6c3b

4 files changed

Lines changed: 50 additions & 33 deletions

File tree

Modules/Core/Common/src/CMakeLists.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,43 @@ if(ITK_USE_TBB)
278278
# Define TBB_USE_CAPTURED_EXCEPTION=0 to request rethrow of the exact exception.
279279
target_compile_definitions(ITKCommon PUBLIC TBB_USE_CAPTURED_EXCEPTION=0)
280280
endif()
281+
282+
if(MSVC)
283+
set(ITK_NATVIS_FILE "${ITK_SOURCE_DIR}/Utilities/Debugger/ITK.natvis")
284+
if(CMAKE_GENERATOR MATCHES "Ninja")
285+
# Ninja/Makefiles Generator support (embeds directly inside the executable's PDB)
286+
target_link_options(
287+
ITKCommon
288+
INTERFACE
289+
"$<BUILD_INTERFACE:/NATVIS:${ITK_NATVIS_FILE}>"
290+
"$<INSTALL_INTERFACE:/NATVIS:${ITK_INSTALL_DATA_DIR}/Debugger/ITK.natvis>"
291+
)
292+
# Force Ninja to re-link if the .natvis file changes
293+
set_property(
294+
TARGET
295+
ITKCommon
296+
APPEND
297+
PROPERTY
298+
LINK_DEPENDS
299+
"${ITK_NATVIS_FILE}"
300+
)
301+
else()
302+
# Visual Studio Generator support (shows up in the Solution Explorer)
303+
target_sources(
304+
ITKCommon
305+
INTERFACE
306+
"$<BUILD_INTERFACE:${ITK_NATVIS_FILE}>"
307+
"$<BUILD_INTERFACE:${ITK_SOURCE_DIR}/Utilities/Debugger/ITK.natjmc>"
308+
"$<INSTALL_INTERFACE:${ITK_INSTALL_DATA_DIR}/Debugger/ITK.natvis>"
309+
"$<INSTALL_INTERFACE:${ITK_INSTALL_DATA_DIR}/Debugger/ITK.natjmc>"
310+
)
311+
endif()
312+
313+
install(
314+
FILES
315+
"${ITK_NATVIS_FILE}"
316+
"${ITK_SOURCE_DIR}/Utilities/Debugger/ITK.natjmc"
317+
DESTINATION ${ITK_INSTALL_DATA_DIR}/Debugger
318+
COMPONENT Development
319+
)
320+
endif()

Utilities/Debugger/ITK.natjmc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Documentation: https://learn.microsoft.com/en-us/visualstudio/debugger/just-my-code?view=visualstudio -->
3+
<NonUserCode xmlns="http://schemas.microsoft.com/vstudio/debugger/jmc/2013">
4+
<Function Name="itk::SmartPointer.*" />
5+
<Function Name="itk::Object::Register" />
6+
<Function Name="vtkSmartPointer.*" />
7+
<!-- We can also disable stepping into STL functions by uncommenting the next line: -->
8+
<!-- <Function Name="std::.+" /> -->
9+
</NonUserCode>

Utilities/Debugger/ITK.natvis

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8" ?>
2-
<!-- Documentation: https://msdn.microsoft.com/en-us/library/jj620914.aspx?f=255&MSPPError=-2147217396 -->
3-
<!-- e.g. copy into C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Packages\Debugger\Visualizers\ITK.natvis -->
2+
<!-- Documentation: https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/debugger/create-custom-views-of-native-objects?view=vs-2015 -->
43
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
54

65
<Type Name="itk::Size&lt;1&gt;">

Utilities/Debugger/default.natstepfilter

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)