Duplicate libraries when linking against both aliased and non-aliased versions of a library
If a library/executable links (transitively or not) against both an alias library and the original non-aliased library, the libraries are duplicated on the linker command line, which causes warnings on the apple linker (potentially others, I didn't check). In an ideal world only the alias-ed library would be linked against in CMake, but library developers don't always follow these rules, in the case I'm dealing with the library developer links directly against the non-aliased name for the library internally but exposes an aliased version that others are expected to link against.
This could be handled gracefully by deduplicating aliased and non-aliased versions of the same library when constructing linker commands.
I put together a minimal project showing the issue here:
https://github.com/jmcken8/cmake-duplicate-lib-bug
Tested on:
- cmake 3.27.7
- cmake 3.28.1