From b44401719c934d0d44f0c30dc58697ff1ca4eb95 Mon Sep 17 00:00:00 2001 From: msclock Date: Mon, 23 Oct 2023 02:23:26 +0800 Subject: [PATCH] perf: change valgrind flow and usage --- cmake/test/Valgrind.cmake | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/cmake/test/Valgrind.cmake b/cmake/test/Valgrind.cmake index 4cb8501..a021db9 100644 --- a/cmake/test/Valgrind.cmake +++ b/cmake/test/Valgrind.cmake @@ -4,36 +4,37 @@ Configure valgrind to check memcheck on testsuit Note: This requires enable the testing. +Example: + + include(Valgrind) + ]] include_guard(GLOBAL) -find_program( - VALGRIND_COMMAND - NAMES valgrind - DOC "valgrind executable") - set(USE_VALGRIND "--leak-check=full --gen-suppressions=all --track-origins=yes" CACHE STRING "use valgrind to check memory issues.") -if(VALGRIND_COMMAND) - message( - STATUS - "Activate valgrind: ${VALGRIND_COMMAND}. - USE_VALGRIND default options: --leak-check=full --gen-suppressions=all --track-origins=yes - Options: - --show-leak-kinds=all - show all possible leak - --gen-suppressions=all - gen suppress info automatically - --track-origins=yes - locates the original position - --suppressions=\"${CMAKE_SOURCE_DIR}/valgrind_suppress.txt\" - use valgrind suppress config file" - ) -endif() +message( + STATUS + "Activate valgrind with USE_VALGRIND: ${USE_VALGRIND} + Options: + --show-leak-kinds=all - show all possible leak + --gen-suppressions=all - gen suppress info automatically + --track-origins=yes - locates the original position + --suppressions=\"\${CMAKE_SOURCE_DIR}/valgrind_suppress.txt\" - use valgrind suppress config file" +) -if(NOT CMAKE_HOST_UNIX) +if(NOT CMAKE_HOST_UNIX OR NOT USE_VALGRIND) message(STATUS "Disable valgrind on non-unix system") return() endif() +find_program( + VALGRIND_COMMAND + NAMES valgrind + DOC "valgrind executable") + if(VALGRIND_COMMAND) set(VALGRIND_COMMAND_OPTIONS "${USE_VALGRIND}") else()