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.
Extend Tests/Dependency with a case covering this behavior. Create an
executable that links to a shared library and a static library but only
needs the shared library as a dependency of the static library.
Co-Author: Brad King <brad.king@kitware.com>
Strong dependencies (created by add_dependencies) must be honored when
linearizing a strongly-connected component of the target dependency
graph. The initial graph edges have strong/weak labels and can contain
cycles that do not consist exclusively of strong edges. The final graph
never contains cycles so all edges can be strong.
A recent change fixed a case in which CMake incorrectly diagnosed a
circular dependency involving a non-linkable executable target. This
adds a test for that case.
- Make sure the original link line is untouched
- Avoid duplicating the link line when supporting version < 1.4
- Make sure the cyclic dependencies and such are output correctly in
complicated cases.
- Avoid outputing dependencies that are already satisfied on the original
link line when possible.