Copy dll's to runtime_output_directory via Imported_Location property?

Lets say I have two shared Libraries A, B and an Executable E.
E depends on B and B depends on A: E -> B -> A

Now assume that A and B are imported shared library targets that have their IMPORTED_LOCATION properly set. Is it somehow possible to copy the dll’s, whose paths are saved in the IMPORTED_LOCATION target properties of A and B, to the output directory of E?

Or do I have to retreat to using file(GET_RUNTIME_DEPENDENCIES) to solve this problem? The difficulty with file(GET_RUNTIME_DEPENDENCIES) is that I’m using hunter package manager to retrieve A and B, so the corresponding dll’s are saved in quite random locations…

IMPORTED_LOCATION is just the location of the linkable .lib file, not the .dll file. file(GET_RUNTIME_DEPENDENCIES) is indeed what I would do here.

I always thought that with an imported shared library on a DLL platform, IMPORTED_LOCATION was supposed to refer to the .dll and IMPORTED_IMPLIB would point to the .lib. I have it set up this way in several projects, and it works. The docs seem to support this too.

Oh right, I forget that all the time :confused: . You could use genexes to extract the information into a script you write out during cmake time I suppose.

Is there a Generator Expression that contains the path to the dll of an imported target?

$<TARGET_FILE:tgt> works for me, as does $<TARGET_PROPERTY:tgt,IMPORTED_LOCATION>, but the former probably plays nicer with configurations.