~compiz-team/compiz/0.9.8

« back to all changes in this revision

Viewing changes to cmake/CompizCommon.cmake

Added compiz_discover_tests.

gtest_add_tests is good for the basic Google Test usage, but its source
based scanning falls short in a couple of areas - namely it requires that
there be no space between TEST* and ( and it also does not work for templated
tests.

compiz_discover_tests builds a small C++ program to parse the output
of --gtest_list_tests and adds those at make-time to the CTestTestfile.cmake
in the current binary directory. This allows us to correctly introspect the test
 binary and get /all/ the tests regardless of the source file.. Fixes: . Approved by Daniel van Vugt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
    set(IS_BZR_REPO 0)
71
71
endif (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.bzr)
72
72
 
 
73
# Create target to discover tests
 
74
function (compiz_discover_tests EXECUTABLE)
 
75
 
 
76
    add_dependencies (${EXECUTABLE}
 
77
                      compiz_discover_gtest_tests)
 
78
 
 
79
    add_custom_command (TARGET ${EXECUTABLE}
 
80
                        POST_BUILD
 
81
                        COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE} --gtest_list_tests | ${CMAKE_BINARY_DIR}/compiz_gtest/compiz_discover_gtest_tests ${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE}
 
82
                        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 
83
                        COMMENT "Discovering Tests in ${EXECUTABLE}"
 
84
                        DEPENDS 
 
85
                        VERBATIM)
 
86
endfunction ()
 
87
 
73
88
function (compiz_ensure_linkage)
74
89
    find_program (LDCONFIG_EXECUTABLE ldconfig)
75
90
    mark_as_advanced (FORCE LDCONFIG_EXECUTABLE)