Hi,

I am trying to use googletest tests on Windows that need external Qt DLLs.

So I tried:

gtest_discover_tests ( \${targetName}UnitTests
TEST_PREFIX \${targetName}.
PROPERTIES
ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:\${QT_RUNTIME_DIR}"
DISCOVERY_MODE PRE_TEST )

However, the environment modification is not honored when running the test discovery.

My alternative is to use configure_file() to create a RunTest.bat that sets up the environment and set the CROSSCOMPILING_EMULATOR property on the executable. This is a lot slower, looks like a hack and thus I would like to avoid that.

I cannot modify the environment outside of the cmake/ctest call because that clumsy, error-prone and also Visual Studio with the RUN_TESTS target is involved.

I do no want to copy the Qt DLLs to the output directory because this also involves plugins and other data, consumes lots of disk space and should not be necessary.

Any ideas? File a bug?

Hendrik

Solved with a generated script that prepends the Qt directory to PATH environment. This is included with

set_property ( DIRECTORY .  APPEND PROPERTY TEST_INCLUDE_FILES \${CMAKE_BINARY_DIR}/QtRuntimeDirInPath.cmake )

This make the test 5x faster than the cmd wrapper!

Still feels like a hack (but a better one)

There’s already an open issue capturing this problem:

https://gitlab.kitware.com/cmake/cmake/-/issues/21453