[CMake] Unit tests, but not CTest

Tyler Roscoe tyler at cryptio.net
Tue Apr 27 10:50:49 EDT 2010


On Tue, Apr 27, 2010 at 02:47:18PM +0100, Magnus Therning wrote:
> Except of course that it will take away one of the things I *really*
> want, which is that all unit tests are run every time I compile.

We run our unit tests with a python wrapper script that does some
environment configuration before running the test. We then add this
script as a post_build custom command so that the unit test runs after
it compiles.

        add_custom_command (TARGET ${PROJECT_NAME}
            POST_BUILD
            # Call the runner script directly. By doing it this way, all the
            # unit tests in the executable run at once. If we call CTest
            # here (like we do for the _runtest target), the script (and
            # thus the python interpreter) is invoked once for each test in
            # the executable, which is slower than calling the script once.
            COMMAND ${PYTHON_EXECUTABLE} ${${PROJECT_NAME}_TESTRUNNER} ${CMAKE_CFG_INTDIR} --gtest_print_time
        )

hth,
tyler


More information about the CMake mailing list