jrl-umi3218/jrl-cmakemodules — Issue #12: Correctly link to libraries in pkg-config macros
Author: sebastiendalibard
Created: 2012-02-08 11:30:37+00:00
State: open

In ubuntu 11.10, ld used as default the option --as-needed, which makes the order of the arguments in the command line important. See:
https://wiki.ubuntu.com/NattyNarwhal/ToolchainTransition

When using cmake macro
set_property($target linker_flags $ldflags)
the linker_flags are placed before the target in the compilation command line, which can lead to improper linkage.

One solution seems to be the use of TARGET_LINK_LIBRARIES($TARGET $LDFLAGS) instead, which places the libraries *after* the target in the command line.

See commit
127e62418f415214d2ea2000fb85bd9391013c03
on branch topic/sdalibar