test/CMakeLists.txt
author Tero Marttila <terom@fixme.fi>
Thu, 07 May 2009 22:23:51 +0300
changeset 186 33ef336dbb4b
child 187 5d100c79521a
permissions -rw-r--r--
rework CMake scripts, particularly re make: Nothing to be done for `test'., integrate lcov now
find_package (LCOV)

# static flags
set (TEST_FLAGS --quiet)

# add utility targets to run the test_harness executable
add_custom_target (test_list
    COMMAND test_harness ${TEST_FLAGS} --list
)

add_custom_target (test
    COMMAND test_harness ${TEST_FLAGS}
)

# add LCOV coverage stuff
if (LCOV_FOUND)
    # static flags
    set (LCOV_FLAGS --quiet)
    set (LCOV_GENHTML_FLAGS --quiet)

    # path to the file generated by `lcov --capture`
    set (LCOV_CAPTURE_PATH ${CMAKE_CURRENT_BINARY_DIR}/lcov-capture-info)

    # unless coverage is disabled
    if (ENABLE_TEST_COVERAGE)
        # add stuff to the test_run taget
        add_custom_command (TARGET test PRE_LINK
            COMMAND ${LCOV_EXECUTABLE} ${LCOV_FLAGS} --directory ${TEST_OBJECT_DIR} --zerocounters
        )

        add_custom_command (TARGET test POST_BUILD
            COMMAND ${LCOV_EXECUTABLE} ${LCOV_FLAGS} --directory ${TEST_OBJECT_DIR} --capture --output-file ${LCOV_CAPTURE_PATH}
            COMMAND ${LCOV_GENHTML_EXECUTABLE} ${LCOV_GENHTML_FLAGS} --output-directory ${CMAKE_CURRENT_BINARY_DIR} ${LCOV_CAPTURE_PATH}
        )
    endif (ENABLE_TEST_COVERAGE)
endif (LCOV_FOUND)