Contributing: Qt Test discovery


I would like to contribute a Qt Test discovery function similar to the one introduced for Google Test in 3.10 (

I have already implemented a minimum viable product. The integration in the CMake repository is straight-forward, but I am unsure about the test strategy.

The gtest_discover_tests() function is called from multiple CMake scripts located in “Tests/RunCMake/GoogleTest/”.


  1. How do I run the tests in Tests/RunCMake/GoogleTest/ locally?
  2. Is this kind of test mandatory for a new feature?
  3. It looks like the gtest_discover_tests() tests in Tests/RunCMake/GoogleTest/ are calling the function, but not checking if it actually does its job. Am I missing something?


1 Like

Hi Olivier, glad to hear there’s some interest in adding this functionality to CMake. @alcroito and perhaps @ben.boeckel may be quite interested in your work.

cd path/to/build/dir
ctest -R "RunCMake.GoogleTest"

We typically do want to have tests for any new features that are added to CMake. For what you are proposing, I think that would apply.

From what I recall, those tests don’t actually build a real gtest binary but instead a fake one so that GoogleTest doesn’t actually have to be available on the system. @matthew-woehlke may be able to give you some guidance on how that works (seems he’s not here on the forums yet though - look him up in CMake’s gitlab).

contribute a Qt Test discovery function

That should be contributed to Qt instead. They have CMake package files through which such functionality can be provided.

A similar offer to add support for Boost Test was made recently and my response was the same. Boost should be able to offer that as part of its CMake package. So can Qt.

OK, not sure if I will have the time to take care of this, but in the meantime I have published the modules on GitHub:

FWIW, I have previously written a Qt test discovery system as part of the SEAL-TK project.

Thanks Kyle, I actually used your code as inspiration. I rewrote it to make it closer to the conventions used in GoogleTest.cmake and made various improvements.