[CMake] Help Please-Link Library

Bill Hoffman bill.hoffman at kitware.com
Mon Jul 16 20:59:57 EDT 2007


Eric Noulard wrote:
> 2007/7/16, Janny Dong <janny.dong at gmail.com>:
>> Hi all,
>>
>> I am using Cmake to build MS Visual C++ program because I am using 
>> VTK. I'd
>> like to link to another thirty-party library in my project. The 
>> library is
>> already installed on my machine by running the executable setup file 
>> . In a
>> project not built by Cmake, all I need to do is just modify the Project
>> Properties: add mylibrary.lib to Linker->Input->Additional 
>> Dependencies. How
>> can I do this in a project built by Cmake? I cannot add it directly 
>> in the
>> Project Properties page because it complains.
>>
>> I am new to Cmake and I got lost in the Cmake commands. Any help 
>> would be
>> appreciated!
>
> You should add a:
>
> TARGET_LINK_LIBRARY to your CMakeLists.txt
> see the documentation of the macro.
>
> in http://www.cmake.org/HTML/Documentation.html
>
> If your lib is not in the lib search path then you need to add the 
> appropriate
> PATH using the LINK_DIRECTORIES macro
>
It is much better to add the full path to the library, and use FIND_LIBRARY.

-Bill




More information about the CMake mailing list