<div class="gmail_quote">On Mon, Nov 14, 2011 at 11:00 AM, David Cole <span dir="ltr"><<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Mon, Nov 14, 2011 at 9:36 AM, Robert Dailey <<a href="mailto:rcdailey@gmail.com">rcdailey@gmail.com</a>> wrote:<br>
> On Mon, Nov 14, 2011 at 6:42 AM, Michael Wild <<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>> wrote:<br>
>><br>
>> Hi Arun<br>
>> Consider LINK_DIRECTORIES to be obsolete and to be avoided at all cost.<br>
><br>
> I don't really agree with this advice. There are circumstances where<br>
> link_directories() is absolutely necessary, so advocating to completely<br>
> avoid it isn't really a one size fits all scenario.<br>
<br>
</div>I agree with the advice entirely. link_directories is completely<br>
*un*necessary if you follow the other advice which is to always use<br>
full path names to library files (or CMake target names) when calling<br>
target_link_libraries.<br>
<br>
I never use link_directories.</blockquote><div><br></div><div>Well maybe you can tell me I'm doing this wrong then, but based on how I am currently setting up my third party libraries, it is required.</div><div><br></div>
<div>So basically all third party libraries we use are not installed individually, instead we have a server on our intranet that contains precompiled versions of all libraries in a specific and consistent hierarchy. For this reason, it doesn't make sense to use find_library(), which would normally always give you absolute paths to your library files and thus link_directories() would not be needed.</div>
<div><br></div><div>Instead I have a script in CMake that iterates each third party library and adds its lib link directory to a list. When done I take this whole list of link directories and pass it to link_directories() in my top level CMakeLists file, this way each and every project will include all of the third party library lib directories to have access to them.</div>
<div><br></div><div>For each target I simply create a list of my libs, like so:</div><div><br></div><div>set( libraries zlib libbdb47 )</div><div><br></div><div>I pass each one of these to target_link_libraries() and I leave it up to the compiler to search for where to find the file in the provided link directories.</div>
</div>