aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorTomasz Moń <desowin@gmail.com>2021-03-29 12:10:16 +0200
committerGuy Harris <gharris@sonic.net>2021-04-10 21:53:59 +0000
commit4bd5830cdaa615a95245e9873f3bae1c42b38dc9 (patch)
tree415bb067d20016fe4f1145df949b0a2c0783f7b7 /CMakeLists.txt
parent1b1a4281b4a02427e34553b248ea50076f184572 (diff)
CMake: Add ENABLE_VLD option for MSVC
Calling cmake with -DENABLE_VLD=ON when building with Visual Studio, results in debug configuration being linked to Visual Leak Detector. By default, Visual Leak Detector outputs the leak summary to Visual Studio debug window. When ENABLE_VLD is active, VLD is linked to all wireshark libraries and executables.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt27
1 files changed, 27 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 52d6d64f5c..a330d9bf68 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -933,6 +933,18 @@ if(ENABLE_FUZZER)
set(CMAKE_CXX_FLAGS "-fsanitize=fuzzer-no-link ${CMAKE_CXX_FLAGS}")
endif()
+if(MSVC)
+ set(ENABLE_VLD OFF CACHE BOOL "Whether enable Visual Leak Detect in Debug configuration")
+ if(ENABLE_VLD)
+ include(FindVLD)
+ if(NOT VLD_FOUND)
+ message(FATAL_ERROR "ENABLE_VLD was requested, but not found!")
+ endif()
+ message(STATUS "Enabling Visual Leak Detector in Debug configuration")
+ set(WS_MSVC_DEBUG_LINK_FLAGS ${VLD_LINK_FLAGS})
+ endif()
+endif()
+
set(WERROR_COMMON_FLAGS "")
if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_COMPILER_WARNINGS)
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
@@ -1913,6 +1925,15 @@ if(WIN32)
COMMAND_EXPAND_LISTS
)
+ if (MSVC AND VLD_FOUND)
+ add_custom_command(TARGET copy_cli_dlls PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} -E "$<IF:$<CONFIG:Debug>,copy_if_different,true>"
+ "${VLD_FILES}"
+ "${_dll_output_dir}"
+ COMMAND_EXPAND_LISTS
+ )
+ endif()
+
# Optional DLLs and PDBs.
set (OPTIONAL_DLLS)
set (OPTIONAL_PDBS)
@@ -2400,6 +2421,9 @@ if(BUILD_wireshark AND QT_FOUND)
FOLDER "Executables"
INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
)
+ if(MSVC)
+ set_target_properties(wireshark PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
+ endif()
if(ENABLE_APPLICATION_BUNDLE OR WIN32)
set_target_properties(wireshark PROPERTIES OUTPUT_NAME Wireshark)
endif()
@@ -2470,6 +2494,9 @@ macro(set_extra_executable_properties _executable _folder)
FOLDER ${_folder}
INSTALL_RPATH "${EXECUTABLE_INSTALL_RPATH}"
)
+ if(MSVC)
+ set_target_properties(${_executable} PROPERTIES LINK_FLAGS_DEBUG "${WS_MSVC_DEBUG_LINK_FLAGS}")
+ endif()
set(PROGLIST ${PROGLIST} ${_executable})