I'm trying to organize auto-copying runtime dependencies of executable targets to its built directories.
As case I use GTest for unit-testing that is linking as shared libraries. After building if I try to launch unit-tests there will be an error like "gtest.dll isn't found". With other external dependencies the same problem (as with local where target is shared library).
I can just add every external library to install process after linking and run tests in that directory but it isn't a practical way as launching CTest.
I wanted to use file(GET_RUNTIME_DEPENDENCIES)
but it must be called after build and I didn't find INSTALL(CODE)
analog for POST_BUILD stage.
Just coping DLLs
with add_custom_command
don't work too because of possible dependency inheritance.
For example, A depends on B that depends on C. If I try to make dependency copying by this approach then only B will be copied in POST_BUILD process of A.
I don't like to store all built artifacts in one directory because it creates a mess and could create collisions in the future.