[CMake] Problem with LINK_DIRECTORIES

Mateusz Łoskot mateusz at loskot.net
Mon Nov 14 13:01:00 EST 2011


On 14 November 2011 17:17, Robert Dailey <rcdailey at gmail.com> wrote:
> 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.

A typical Linux user can say the same: I have all my libraries in /usr/lib
so it does not make sense to use find_library.
No point arguing if it would make sense or not.
Simply, find_library is a unified convention used by CMake, it works regardless
user-specific filesystem structure.

Simply, it would not hurt to use find_library().
Then, you can follow the CMake convention, without a need of custom
scripts, etc.

> 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.

IMO, you don't buy anything with this customisation.
Either CMake finds library and tells compiler "look, it's here"
or CMake + custom script approximates library location
and lets linker to find it.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
Member of ACCU, http://accu.org


More information about the CMake mailing list