file(GET_RUNTIME_DEPENDENCIES): Fix resolution of repeated ELF dependencies

When a library file name is encountered multiple times, reuse the result
from the first time.  This more closely matches the behavior of the
dynamic loader on Linux.

Fixes: #24621
8 files changed