gtest_discover_tests(): Honor TEST_LAUNCHER when obtaining test list
Originally raised in the forums here: https://discourse.cmake.org/t/wrapping-tests-discovered-by-gtest-discover-tests-into-a-wrapper/9852/2
The `gtest_discover_tests()` command runs the test executable with options to ask it to provide the list of tests it defines. !8963 added a new `TEST_LAUNCHER` test property, which allows projects to wrap the test executable. It may be desirable for that test launcher to also be used when running the test discovery step in `gtest_discover_tests()`. Depending on what the test launcher does, this might even be necessary.
One complication is that the test discovery can be done as either a `POST_BUILD` step at build time, or as a `PRE_TEST` step at test time. It seems wrong to use a test launcher for `POST_BUILD`, but right to use one for `PRE_TEST`. Potentially we could consider using `TEST_LAUNCHER` only for the `PRE_TEST` case and not for `POST_BUILD`.
It is worth comparing against the behavior of the `CROSSCOMPILING_EMULATOR` target property. This is honoured during test discovery, for both `POST_BUILD` and `PRE_TEST`. However, `CROSSCOMPILING_EMULATOR` is a target property, not a test property, so that still makes sense to use it for `POST_BUILD`.
issue