Fix link line order when shared libraries are de-duplicated

Since commit v3.1.0-rc1~227^2~1 (De-duplicate shared library targets in
generated link lines, 2014-07-30) we de-duplicate shared library targets
on the link line.  However, some toolchains will fail linking if an
executable is linking to a shared library that is not used directly and
a static library that depends on the shared one.  The linker may not
keep the reference to the shared library the first time and then the
symbols needed by the static library may not be found.

Fix this by reversing the direction of the for loop that removes the
duplicate shared libraries, in order to ensure that the last occurrence
of the library is left instead of the first one.

Co-Author: Brad King <brad.king@kitware.com>
Test linking to a shared lib needed only through a static lib
Merge topic 'fix_link-line-dedup_regression' into next

a4716b6b Test linking to a shared lib needed only through a static lib
3c3589e1 Fix link line order when shared libraries are de-duplicated