How to properly use TEST_XML_OUTPUT_DIR?

I’m writing a CI script for an existing repository.

I would like to simply run all the gtest-based unit tests with ctest (in parallel, if possible) and store the summary into one or more xml files, so that the CI system knows where to look for them and can display the results in some user-friendly way.

I’ve seen https://github.com/google/googletest/issues/2506 which points to the recently added TEST_XML_OUTPUT_DIR in commit https://gitlab.kitware.com/cmake/cmake/-/commit/e9ab39eb1db8f072b030a929992df828bc05cc63, but I struggle to understand how to use this without the need to change the CMakeLists.txt itself. According to my understanding this variable needs to be added to gtest_discover_tests()? Is this really the only way?

I mean: In the same way as I wouldn’t want to hardcode /home/penguin/mycoolnewicecreamproject/build/x86_64-linux-clang inside CMakeLists.txt as the directory where the project is supposed to be built on my own machine, I wouldn’t want to hardcode the directory where I want to have my google tests results either. (I don’t want to hardcode that the results should be in xml format either.)

I tried a couple of things in the command-line, but I didn’t get any of those working according to my expectations.