Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics.
[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("-- Found valgrind: ${VALGRIND_EXE}")
14 SET(VALGRIND_COMMAND "${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/my_valgrind.pl")
15 SET(MEMORYCHECK_COMMAND "${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/my_valgrind.pl")
16 endif(VALGRIND_EXE)
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("-- Valgrind version: ${NEW_VALGRIND_VERSION}")
23                 exec_program("${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/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 --leak-check=full --show-reachable=yes --track-origins=yes --read-var-info=no")
25                 message("-- Valgrind options: ${MEMORYCHECK_COMMAND_OPTIONS}")
26         else(NEW_VALGRIND_VERSION)
27                 set(enable_memcheck false)
28                 message("-- Error: Command valgrind not found --> enable_memcheck autoset to false.")
29         endif(NEW_VALGRIND_VERSION)
30 else(VALGRIND_EXE)
31         set(enable_memcheck false)
32         message(FATAL_ERROR "Command valgrind not found --> enable_memcheck autoset to false.")
33 endif(VALGRIND_EXE)