@@ -215,12 +215,49 @@ function(__boost_install_update_include_directory lib incdir prop)
215
215
216
216
endfunction ()
217
217
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
+
218
255
# 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] )
220
257
221
258
function (boost_install_target)
222
259
223
- cmake_parse_arguments (_ "" "TARGET;VERSION;HEADER_DIRECTORY" "" ${ARGN} )
260
+ cmake_parse_arguments (_ "" "TARGET;VERSION;HEADER_DIRECTORY;EXTRA_DIRECTORY " "" ${ARGN} )
224
261
225
262
if (NOT __TARGET)
226
263
@@ -317,6 +354,10 @@ function(boost_install_target)
317
354
if (TYPE STREQUAL "STATIC_LIBRARY" AND NOT CMAKE_VERSION VERSION_LESS 3.15)
318
355
install (FILES "$<TARGET_FILE_DIR:${LIB} >/$<TARGET_FILE_PREFIX:${LIB} >$<TARGET_FILE_BASE_NAME:${LIB} >.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL )
319
356
endif ()
357
+
358
+ if (__EXTRA_DIRECTORY)
359
+ __boost_install_update_natvis(${LIB} ${__EXTRA_DIRECTORY} )
360
+ endif ()
320
361
endif ()
321
362
322
363
install (EXPORT ${LIB} -targets DESTINATION "${CONFIG_INSTALL_DIR} " NAMESPACE Boost:: FILE ${LIB} -targets.cmake)
@@ -560,7 +601,7 @@ function(boost_install)
560
601
561
602
foreach (target IN LISTS __TARGETS)
562
603
563
- boost_install_target(TARGET ${target} VERSION ${__VERSION} HEADER_DIRECTORY ${__HEADER_DIRECTORY} )
604
+ boost_install_target(TARGET ${target} VERSION ${__VERSION} HEADER_DIRECTORY ${__HEADER_DIRECTORY} EXTRA_DIRECTORY ${__EXTRA_DIRECTORY} )
564
605
565
606
endforeach ()
566
607
0 commit comments