# Contributing: Qt Test discovery

**URL:** https://discourse.cmake.org/t/contributing-qt-test-discovery/985
**Category:** Development
**Created:** [April 11, 2020, 11:14am UTC](https://discourse.cmake.org/t/contributing-qt-test-discovery/985 "2020-04-11T11:14:40Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ocroquette](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/dbc845/32.png) [@ocroquette](https://discourse.cmake.org/u/ocroquette)
#### Post date: [April 11, 2020, 11:14am UTC](https://discourse.cmake.org/t/contributing-qt-test-discovery/985/1 "2020-04-11T11:14:40Z")

</div>

Hello,

I would like to contribute a Qt Test discovery function similar to the one introduced for Google Test in 3.10 ([https://blog.kitware.com/dynamic-google-test-discovery-in-cmake-3-10/](https://blog.kitware.com/dynamic-google-test-discovery-in-cmake-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/”.

Questions:

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?

Thanks,  
Olivier

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [April 11, 2020, 1:32pm UTC](https://discourse.cmake.org/t/contributing-qt-test-discovery/985/2 "2020-04-11T13:32:49Z")

</div>

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.

> [@ocroquette](#):
>
> - How do I run the tests in Tests/RunCMake/GoogleTest/ locally?

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

```

> [@ocroquette](#):
>
> - Is this kind of test mandatory for a new feature?

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.

> [@ocroquette](#):
>
> - 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?

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](https://gitlab.kitware.com/matthew-woehlke)).

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [April 13, 2020, 11:55am UTC](https://discourse.cmake.org/t/contributing-qt-test-discovery/985/3 "2020-04-13T11:55:16Z")

</div>

> 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.

---

<div class="post-metadata">

### Author: ![ocroquette](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/dbc845/32.png) [@ocroquette](https://discourse.cmake.org/u/ocroquette)
#### Post date: [April 13, 2020, 4:17pm UTC](https://discourse.cmake.org/t/contributing-qt-test-discovery/985/4 "2020-04-13T16:17:43Z")

</div>

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: [https://github.com/ocroquette/cmake-qtest-discovery](https://github.com/ocroquette/cmake-qtest-discovery)

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [April 13, 2020, 4:39pm UTC](https://discourse.cmake.org/t/contributing-qt-test-discovery/985/5 "2020-04-13T16:39:59Z")

</div>

FWIW, I have previously written a Qt test discovery system as part of the [SEAL-TK](https://github.com/Kitware/seal-tk/blob/master/cmake/SEALTKUtils.cmake#L8) project.

---

<div class="post-metadata">

### Author: ![ocroquette](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/dbc845/32.png) [@ocroquette](https://discourse.cmake.org/u/ocroquette)
#### Post date: [April 13, 2020, 4:46pm UTC](https://discourse.cmake.org/t/contributing-qt-test-discovery/985/6 "2020-04-13T16:46:18Z")

</div>

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.
