Skip to content

Commit

Permalink
perf: change valgrind flow and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
msclock committed Oct 22, 2023
1 parent 4e53c96 commit b444017
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions cmake/test/Valgrind.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b444017

Please sign in to comment.