[CMake] more linking problems
Brad King
brad.king at kitware.com
Fri Apr 22 09:13:42 EDT 2005
Alexander Neundorf wrote:
>>Turn on CMAKE_SKIP_RPATH to avoid getting the build-tree rpath compiled
>>in and then just specify the library by name "kinterfacedesigner".
>
> You mean like:
> TARGET_LINK_LIBRARIES (blah
> ${CMAKE_BINARY_DIR}/lib/interfaces/external/kinterfacedesigner ) ?
>
> And this will work ?
No, just
TARGET_LINK_LIBRARIES(blah kinterfacedesigner)
I'm assuming that kinterfacedesigner is a library built in another
directory in the same CMake project. In that case CMake knows where to
find the library and how to link it.
>>install location should not matter as long as the system is configured
>>with the proper library search paths. Several linux distributions ban
>>rpaths from their binaries, so avoiding rpaths is generally considered
>>good for installed packages. CMake adds rpaths by default so that
>>shared-library builds can work out-of-the-box from the build tree.
>
> Ah, ok.
> (What is actually the rpath ?)
The rpath is the "runtime path" for loading shared libraries. It is a
list of places for the dynamic linker to look to find the required
shared libraries. Executables can have an rpath for their shared
libraries. Shared libraries can have an rpath for other shared
libraries on which they depend.
CMake by default adds all the link directories to the rpath of shared
libraries and executables so that any libraries linked in at build time
can be found at runtime. This way executables can run from the build
tree without the user having to set LD_LIBRARY_PATH appropriately.
> Now I found something in the mailing list archive:
> http://public.kitware.com/pipermail/cmake/2004-December/005907.html
> I think I'll try this. Would it be also possible to add a static lib
> there ?
That's an interesting idea. Basically we would just add the ability to
list a static library as a source file similar to the current external
object feature. It would let us add the ability to pull entire static
libraries into the link line instead of just individual object files.
Just as with external objects it would be up to the listfile author to
ensure that the object files in the archive are built properly.
There is a small chance this will just work if you try it. Please let
me know whether it works. If not I'll put it on my to-do list to implement.
-Brad
More information about the CMake
mailing list