[CMake] GoogleTest integration with CTest

Chad Gilbert chad.s.gilbert at gmail.com
Thu Mar 8 10:29:00 EST 2018

​Hi all,

I'm a new poster on this list. It's nice to meet you.

​ was very excited when I came across the new support for GoogleTest test
discovery in CMake (
However, this new approach and the older one both play very poorly with any
of my tests that require fixtures.

The situation I have is this: I have about a hundred tests defined which
rely on a socket connection that has to pass a few messages each time it's
initialized. I define a static test fixture in GoogleTest to make the
connection to start the socket connection and initialize the server, then
run all of the tests and clean up once when they're all done.

The problem is that when I use `gtest_discover_tests()` (or
`gtest_add_tests()`), CTest breaks all of the tests apart into separate
processes, adding a couple seconds overhead to each test (the tests
themselves take on average a millisecond to run). Perhaps that's still
acceptable for now where I've only got ~100 tests that depend on that
fixture, but I worry my list of tests will still grow, and it smells like
that penalty should be avoidable somehow.

I don't necessarily need to be able to see the output of every CTest
(though that's a nice-to-have). What I really need is to be able to see all
of the test results in my project CDash. Is there any way to have
GoogleTest supply its own test results to CDash such that the GTest
executable is only run once, but all of the individual test results can be


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180308/fd3934bf/attachment-0001.html>

More information about the CMake mailing list