[CMake] Baffled by CDT4 link_directories

Rolf Eike Beer eike at sf-mail.de
Fri May 6 02:06:08 EDT 2011


Am Donnerstag, 5. Mai 2011, 22:21:49 schrieb Dan Furtney:
> I have a CMakelists.txt file that works properly for the “Unix Makefiles”
> type build (Linux) and for VS 2008. When generating a CDT4 project (Linux)
> from the same file, library paths are not resolved and the project won’t
> link. The library paths are specified using the link_directories command
> exclusively.  The cmake files are at the same level as the “Src” 
directory
> that contains all source. I am totally stumped as to why this doesn’t work
> under CDT4.

The answer is rather simple: don't use link_directories(). If you use it and 
it gives you trouble that means that you don't understand what it does and 
that means that you don't need it. Really. Use target_link_libraries() with a 
full path to the library you want to use and let CMake do everything else.

Can we please get a big fat warning message into the link_directories() 
documentation telling people that if they come from Makefiles or whereever they 
should not use this function as this works different than in plain makefiles and 
is usually a bad idea to use? I'm often doing support in #cmake on Freenode 
and this is likely the most misunderstood concept of everyone coming from 
plain Makefiles.

Eike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110506/ab25162a/attachment.pgp>


More information about the CMake mailing list