[CMake] Build/Link with static libs
Brad King
brad.king at kitware.com
Wed May 3 10:10:09 EDT 2006
Christian Lang wrote:
>> Christian Lang wrote:
>>> Alexander Neundorf schrieb:
>>> my first problem is solved: To link against "foo/libbar.a", the link
>>> line options "-Lfoo -lbar" are produced. This works. But what if for
>>> some reason I do not want to use it this way, but want to directly
>>> specify "foo/libbar.a" at the link line (as I tried in the first
>>> place)? Is this possible?
>>
>> You can specify the full path to libbar.a
>>
> Ok, but if I specify - for instance - "/path/foo/libbar.a"
> (TARGET_LINK_LIBRARIES), cmake transforms it to "-L/path/foo -lbar" at
> the link line ...
That's because on most platforms passing the full path to a static
library causes the linker to copy the entire archive instead of just the
objects needed. CMake splits the path into -L and -l to avoid this
problem, but it also computes a safe link directory order to make sure
the library is found at the location specified. It warns if no safe
order exists.
-Brad
More information about the CMake
mailing list