And I believe (not confirmed) the reason why is because gtest_discover_tests runs the binary before my "copy runtime DLLs" POST_BUILD action, which is necessary for running windows executables because they don't have an rpath etc.:
The fix for this was to tell CMake exactly which TARGET_RUNTIME_DLLS are needed on Windows, and to make the build command copy the runtime binaries in a PRE_BUILD step
This action fails:
With this error:
Because of this changeset ("works on my machine"):
And I believe (not confirmed) the reason why is because
gtest_discover_tests
runs the binary before my "copy runtime DLLs"POST_BUILD
action, which is necessary for running windows executables because they don't have anrpath
etc.:Thanks to @zonmen for mentioning the idea of this being the problem on a googletest issue: