[CMake] To avoid target_link_libraries magic
Brad King
brad.king at kitware.com
Mon Mar 21 10:30:58 EDT 2011
On 3/21/2011 10:12 AM, Valeriy Bykov wrote:
> I'm using CMake version 2.8.4. Furthermore I use custom ToolChain but I
> don't think it is important.
>
> ... /home/vbykov/svn/builddeps/glibc/lib/libpthread.a
It may be important actually. Is this path to libpthread.a in the
implicit library search path for the toolchain? What is the full
link line produced?
CMake behaves a bit differently for targets in implicit link
directories. Instead of using the full path it converts the
library to '-lpthread' knowing that the linker will find it.
This is because some toolchains substitute architecture-specific
implicit link directories at the last moment.
One may always use IMPORTED targets to tell CMake _exactly_ what
path to use for a library:
http://www.cmake.org/Wiki/CMake/Tutorials/Exporting_and_Importing_Targets#Importing_Targets
See also the documentation here for why -B(static|dynamic) appear:
http://www.cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:LINK_SEARCH_END_STATIC
and a recent change I made to help folks that want static linking:
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5abfb571
A version of CMake with this change is available as a nightly binary:
http://www.cmake.org/files/dev/?C=M;O=D
-Brad
More information about the CMake
mailing list