summaryrefslogtreecommitdiffstats
path: root/test.cmake
blob: 527816fa5e65124dd60ad9dc99180c203eb1ce51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
SET(TESTING OFF CACHE BOOL "Build tests")

IF (TESTING)
    ENABLE_TESTING()
ENDIF (TESTING)

MACRO (MAKE_TEST testvariable valgrindvariable libraries class)
    KDE4_ADD_UNIT_TEST(test-${class}
        Test${class}.cpp
    )
    TARGET_LINK_LIBRARIES(test-${class}
        ${QT_QTCORE_LIBRARY}
        ${QT_QTTEST_LIBRARY}
        ${${libraries}}
    )
    SET(${variable}
        ${${variable}}
        test-${class}
    )
    IF (UNIX)
        ADD_CUSTOM_TARGET(valgrind-${class}
            COMMAND
                valgrind
                    --leak-check=full
                    --show-reachable=yes
                    --log-file=${EXECUTABLE_OUTPUT_PATH}/${class}.valgrind
                    bin/test-${class}
            DEPENDS
                test-${class}
            WORKING_DIRECTORY
                ${CMAKE_BINARY_DIR}
            COMMENT
                "Running valgrind on ${class}"
        )
        SET(${valgrindvariable}
            ${${valgrindvariable}}
            valgrind-${class}
        )
    ENDIF (UNIX)
ENDMACRO (MAKE_TEST)

MACRO (MAKE_TEST_GROUP groupname tests)
    ADD_CUSTOM_TARGET(tests-${groupname}
        DEPENDS
            ${${tests}}
    )
ENDMACRO (MAKE_TEST_GROUP)

MACRO (MAKE_VALGRIND_GROUP groupname tests)
    IF (UNIX)
        ADD_CUSTOM_TARGET(valgrind-${groupname}
            DEPENDS
                ${${tests}}
        )
    ENDIF (UNIX)
ENDMACRO (MAKE_VALGRIND_GROUP)