Order of link directories

David Faure faure at kde.org
Mon Feb 5 15:31:15 CET 2007


On Monday 05 February 2007, Brad King wrote:
> David Faure wrote:
> > On Friday 02 February 2007, Alexander Neundorf wrote:
> >> On Friday 02 February 2007 21:46, David Faure wrote:
> >>> What makes up the order of the link directories with cmake?
> >>> `cmake --help-command link_directories` doesn't mention what happens when
> >>> calling it multiple times, and I also don't know where builddir/lib gets
> >>> added to the link directories.
> >> As soon as you say 
> >> target_link_libraries(someapp somelib)
> >> and "somelib" is built in the same build, the directory where the library is 
> >> created is added to the link path.
> >> Finally there is some clever sorting algorithm in cmake which tries to get the 
> >> order right.
> > For some definition of clever, since it gets it wrong here ;)
> 
> It gets it right if you never use LINK_DIRECTORIES and just always give
> the full path to all desired libraries.

Thanks. I'll remove link_directories (${KDE4_LIB_DIR}) from all modules.

> Given the full path to all desired libs, CMake actually inspects the
> contents of all the directories.  A partial ordering of the link
> directories is constructed.  It determines an order for the link
> directories to make sure the linker will choose the correct copy of each
> library.  If no such order exists a warning is issued.  The order on the
> command line that you see will work unless new libs were installed
> between running cmake and running make.

Ah, so *if* I had a kde4 installed in /usr/lib I would get a different -L order, and
(unless it wasn't possible), it would still work. I see. Excellent, thanks!

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).


More information about the Kde-buildsystem mailing list