[CMake] Problem with LINK_DIRECTORIES

Robert Dailey rcdailey at gmail.com
Mon Nov 14 09:36:38 EST 2011


On Mon, Nov 14, 2011 at 6:42 AM, Michael Wild <themiwi at gmail.com> wrote:

> Hi Arun
>
> Consider LINK_DIRECTORIES to be obsolete and to be avoided at all cost.


I don't really agree with this advice. There are circumstances where
link_directories() is absolutely necessary, so advocating to completely
avoid it isn't really a one size fits all scenario.

What I've done is make sure that link_directories() is called from a parent
level directory, so that all projects inherit the directories. In cases
where you do not have a hierarchy setup like this, then call
link_directories() once with the same directories before each call to
add_executable, add_library, etc.

Also one unrelated note, but static libraries do not require any
dependencies to be linked in when it is built. You only need your third
party libraries in your shared library or executable that links against the
static library in question.

Hope this helps.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111114/d989fe59/attachment.htm>


More information about the CMake mailing list