[CMake] Problem with LINK_DIRECTORIES

David Cole david.cole at kitware.com
Mon Nov 14 12:00:51 EST 2011


On Mon, Nov 14, 2011 at 9:36 AM, Robert Dailey <rcdailey at gmail.com> wrote:
> 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.

I agree with the advice entirely. link_directories is completely
*un*necessary if you follow the other advice which is to always use
full path names to library files (or CMake target names) when calling
target_link_libraries.

I never use link_directories.


> 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.
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


More information about the CMake mailing list