@@ -215,12 +215,49 @@ function(__boost_install_update_include_directory lib incdir prop)
215215
216216endfunction ()
217217
218+ function (__boost_install_update_natvis lib extradir)
219+
220+ if (NOT TARGET "${lib} " OR NOT lib MATCHES "^boost_(.*)$" )
221+ return ()
222+ endif ()
223+
224+ get_target_property (sources ${lib} INTERFACE_SOURCES)
225+ if (NOT sources )
226+ return ()
227+ endif ()
228+
229+ foreach (src IN LISTS sources )
230+
231+ # Look for .natvis files in the given extra directory
232+ if (src MATCHES "\\ ${extradir} \\ /(.*)\\ .natvis" )
233+
234+ set (natvis_file "${CMAKE_MATCH_1} .natvis" )
235+
236+ if ("${src} " STREQUAL "${extradir} /${natvis_file} " OR "${src} " STREQUAL "$<BUILD_INTERFACE:${extradir} /${natvis_file} >" )
237+
238+ # Remove this .natvis file from the INTERFACE_SOURCES target property,
239+ # only if it appears as a direct path, not a generator expression.
240+ get_target_property (modified_sources ${lib} INTERFACE_SOURCES)
241+ list (REMOVE_ITEM modified_sources "${extradir} /${natvis_file} " )
242+ set_target_properties (${lib} PROPERTIES INTERFACE_SOURCES "${modified_sources} " )
243+
244+ # Add this .natvis file to the INTERFACE_SOURCES target property, prefixed properly.
245+ target_sources ("${lib} " INTERFACE $<BUILD_INTERFACE:${extradir} /${natvis_file} > $<INSTALL_INTERFACE:${CMAKE_INSTALL_DATADIR} /${natvis_file} >)
246+
247+ endif ()
248+
249+ endif ()
250+
251+ endforeach ()
252+
253+ endfunction ()
254+
218255# Installs a single target
219- # boost_install_target(TARGET target VERSION version [HEADER_DIRECTORY directory])
256+ # boost_install_target(TARGET target VERSION version [HEADER_DIRECTORY directory] [EXTRA_DIRECTORY directory] )
220257
221258function (boost_install_target)
222259
223- cmake_parse_arguments (_ "" "TARGET;VERSION;HEADER_DIRECTORY" "" ${ARGN} )
260+ cmake_parse_arguments (_ "" "TARGET;VERSION;HEADER_DIRECTORY;EXTRA_DIRECTORY " "" ${ARGN} )
224261
225262 if (NOT __TARGET)
226263
@@ -317,6 +354,10 @@ function(boost_install_target)
317354 if (TYPE STREQUAL "STATIC_LIBRARY" AND NOT CMAKE_VERSION VERSION_LESS 3.15)
318355 install (FILES "$<TARGET_FILE_DIR:${LIB} >/$<TARGET_FILE_PREFIX:${LIB} >$<TARGET_FILE_BASE_NAME:${LIB} >.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL )
319356 endif ()
357+
358+ if (__EXTRA_DIRECTORY)
359+ __boost_install_update_natvis(${LIB} ${__EXTRA_DIRECTORY} )
360+ endif ()
320361 endif ()
321362
322363 install (EXPORT ${LIB} -targets DESTINATION "${CONFIG_INSTALL_DIR} " NAMESPACE Boost:: FILE ${LIB} -targets.cmake)
@@ -553,7 +594,7 @@ function(boost_install)
553594
554595 foreach (target IN LISTS __TARGETS)
555596
556- boost_install_target(TARGET ${target} VERSION ${__VERSION} HEADER_DIRECTORY ${__HEADER_DIRECTORY} )
597+ boost_install_target(TARGET ${target} VERSION ${__VERSION} HEADER_DIRECTORY ${__HEADER_DIRECTORY} EXTRA_DIRECTORY ${__EXTRA_DIRECTORY} )
557598
558599 endforeach ()
559600
0 commit comments