Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / tools / 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}/tools/cmake/scripts/my_valgrind.pl")
15   SET(MEMORYCHECK_COMMAND "${CMAKE_HOME_DIRECTORY}/tools/cmake/scripts/my_valgrind.pl")
16 endif()
17
18 if(enable_memcheck_xml)
19   SET(VALGRIND_EXTRA_COMMAND_OPTIONS "--xml=yes --xml-file=memcheck_test_%p.memcheck --child-silent-after-fork=yes")
20 endif()
21
22 if(VALGRIND_EXE)
23   execute_process(COMMAND ${VALGRIND_EXE} --version  OUTPUT_VARIABLE "VALGRIND_VERSION")
24   string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" NEW_VALGRIND_VERSION "${VALGRIND_VERSION}")
25   if(NEW_VALGRIND_VERSION)
26     message(STATUS "Valgrind version: ${NEW_VALGRIND_VERSION}")
27     execute_process(COMMAND ${CMAKE_HOME_DIRECTORY}/tools/cmake/scripts/generate_memcheck_tests.pl ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/tools/cmake/Tests.cmake OUTPUT_FILE ${CMAKE_BINARY_DIR}/memcheck_tests.cmake)
28     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 --num-callers=20 --suppressions=${CMAKE_HOME_DIRECTORY}/tools/simgrid.supp ${VALGRIND_EXTRA_COMMAND_OPTIONS} ")
29     message(STATUS "Valgrind options: ${MEMORYCHECK_COMMAND_OPTIONS}")
30   else()
31     set(enable_memcheck false)
32     message(STATUS "Error: Command valgrind not found --> enable_memcheck autoset to false.")
33   endif()
34 else()
35   set(enable_memcheck false)
36   message(FATAL_ERROR "Command valgrind not found --> enable_memcheck autoset to false.")
37 endif()
38
39 mark_as_advanced(VALGRIND_EXE)