[CMake] How to extract the directory path from find_library ?
Mateusz Loskot
mateusz at loskot.net
Fri Dec 14 09:56:59 EST 2012
On 14 December 2012 13:32, Rolf Eike Beer <eike at sf-mail.de> wrote:
> 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().
Indeed and this should be well explained in the documentation.
I've met countless cases and users who are confused [1] about
file path vs folder path returned from the find_library and related commands.
Many, if not most those new to CMake still think along the configuration
of Visual Studio project with separate properties for library folder
and library names.
[1] http://www.cmake.org/pipermail/cmake/2012-December/052909.html
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
More information about the CMake
mailing list