2 # - Find Visual Leak Detector
4 # VLD_LINK_FLAGS - MSVC linker flags that enable VLD
5 # VLD_FILES - files that should be copied to dll output directory
6 # VLD_VALID - TRUE if Visual Leak Detector was found
8 set(_PF86 "PROGRAMFILES(x86)")
10 set(_vld_dll vld_x64.dll)
11 set(_vld_pdb vld_x64.pdb)
12 if(WIRESHARK_TARGET_PLATFORM MATCHES "win32")
14 set(_vld_dll vld_x86.dll)
15 set(_vld_pdb vld_x86.pdb)
18 find_library(VLD_LIBRARY
22 "$ENV{PROGRAMFILES}/Visual Leak Detector/lib/${_vld_arch}"
23 "$ENV{${_PF86}}/Visual Leak Detector/lib/${_vld_arch}"
24 "$ENV{PROGRAMW6432}/Visual Leak Detector/lib/${_vld_arch}"
27 function(find_vld_file _vld_file _filename)
28 find_file(${_vld_file}
32 "$ENV{PROGRAMFILES}/Visual Leak Detector/bin/${_vld_arch}"
33 "$ENV{${_PF86}}/Visual Leak Detector/bin/${_vld_arch}"
34 "$ENV{PROGRAMW6432}/Visual Leak Detector/bin/${_vld_arch}"
36 if(${${_vld_file}} STREQUAL "${_vld_file}-NOTFOUND")
37 set(${_vld_file} "" PARENT_SCOPE)
41 find_vld_file(VLD_DLL ${_vld_dll})
42 find_vld_file(VLD_DBGHELP_DLL "dbghelp.dll")
43 find_vld_file(VLD_MANIFEST "Microsoft.DTfW.DHL.manifest")
44 find_vld_file(VLD_PDB ${_vld_pdb})
46 #library, dlls and manifest are mandatory, while pdb is optional
47 IF(VLD_LIBRARY AND (EXISTS ${VLD_DLL}) AND (EXISTS ${VLD_DBGHELP_DLL}) AND (EXISTS ${VLD_MANIFEST}))
48 # Link against VLD library and force it to be linked by referencing symbol
49 # Adding VLD_LINK_FLAGS to linker flags enables Visual Leak Detector
50 set(VLD_LINK_FLAGS "\"${VLD_LIBRARY}\" /include:__imp_?g_vld@@3VVisualLeakDetector@@A")