Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Set valgrind option --track-origins=no, to make it use less memory.
[simgrid.git] / buildtools / Cmake / Modules / FindValgrind.cmake
1 find_program(VALGRIND_EXE
2   NAME valgrind
3   PATH_SUFFIXES bin/
4   PATHS
5   /opt
6   /opt/local
7   /opt/csw
8   /sw
9   /usr
10   )
11
12 if(VALGRIND_EXE)
13   message(STATUS "Found valgrind: ${VALGRIND_EXE}")
14   SET(VALGRIND_COMMAND "${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Scripts/my_valgrind.pl")
15   SET(MEMORYCHECK_COMMAND "${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Scripts/my_valgrind.pl")
16 endif()
17
18 if(VALGRIND_EXE)
19   exec_program("${VALGRIND_EXE} --version " OUTPUT_VARIABLE "VALGRIND_VERSION")
20   string(REGEX MATCH "[0-9].[0-9].[0-9]" NEW_VALGRIND_VERSION "${VALGRIND_VERSION}")
21   if(NEW_VALGRIND_VERSION)
22     message(STATUS "Valgrind version: ${NEW_VALGRIND_VERSION}")
23     exec_program("${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/Scripts/generate_memcheck_tests.pl ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/AddTests.cmake > ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/memcheck_tests.cmake" OUTPUT_VARIABLE SHUTT)
24     set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --trace-children-skip=/usr/bin/*,/bin/* --leak-check=full --show-reachable=yes --track-origins=no --read-var-info=no")
25     message(STATUS "Valgrind options: ${MEMORYCHECK_COMMAND_OPTIONS}")
26   else()
27     set(enable_memcheck false)
28     message(STATUS "Error: Command valgrind not found --> enable_memcheck autoset to false.")
29   endif()
30 else()
31   set(enable_memcheck false)
32   message(FATAL_ERROR "Command valgrind not found --> enable_memcheck autoset to false.")
33 endif()
34
35 mark_as_advanced(VALGRIND_EXE)