[CMake] How to extract the directory path from find_library ?

Rolf Eike Beer eike at sf-mail.de
Fri Dec 14 08:32:18 EST 2012


Am , schrieb Witold E Wolski:
> Hi,
>
> I am using
>
> FIND_LIBRARY(CPPUNIT_LIBRARY NAMES cppunit HINTS
> ${CPPUNIT_INCLUDE_DIR}/../lib)
>
>
> to find library locations. But what I am needing is the directory
> containing the lib and not the full path.
> How do I get it?

cmake --help-command get_filename_component

And if you think about using that for linking: all you need is the full 
path. Just pass that to target_link_libraries. Don't even think about 
messing around with link_directories().

Eike


More information about the CMake mailing list