~unity-team/libqtdbusmock/trunk

« back to all changes in this revision

Viewing changes to cmake/FindValgrind.cmake

  • Committer: Bileto Bot
  • Author(s): Pete Woods
  • Date: 2017-01-06 10:44:18 UTC
  • mfrom: (45.1.1 stable)
  • Revision ID: ci-train-bot@canonical.com-20170106104418-gvma1zy1zykerf62
Compatibility with unversioned cmake-extras modules (LP: #1563573)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
option(
3
 
  ENABLE_MEMCHECK_OPTION
4
 
  "If set to ON, enables automatic creation of memcheck targets"
5
 
  OFF
6
 
)
7
 
 
8
 
find_program(
9
 
        VALGRIND_PROGRAM
10
 
        NAMES valgrind
11
 
)
12
 
 
13
 
if(VALGRIND_PROGRAM)
14
 
        set(VALGRIND_PROGRAM_OPTIONS
15
 
                "--suppressions=${CMAKE_SOURCE_DIR}/tests/data/valgrind.suppression"
16
 
                "--error-exitcode=1"
17
 
                "--leak-check=full"
18
 
                "--gen-suppressions=all"
19
 
                "--show-leak-kinds=definite"
20
 
                "--quiet"
21
 
        )
22
 
endif()
23
 
 
24
 
find_package_handle_standard_args(
25
 
        VALGRIND DEFAULT_MSG
26
 
        VALGRIND_PROGRAM
27
 
)
28
 
 
29
 
function(add_valgrind_test NAME EXECUTABLE)
30
 
        if(ENABLE_MEMCHECK_OPTION AND VALGRIND_PROGRAM)
31
 
                add_test(${NAME} ${VALGRIND_PROGRAM} ${VALGRIND_PROGRAM_OPTIONS} "${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE}")
32
 
        else()
33
 
                add_test(${NAME} ${EXECUTABLE})
34
 
        endif()
35
 
endfunction()