[CMake] dependency problem

Michael Hertling mhertling at online.de
Tue Jun 8 18:30:24 EDT 2010


On 06/08/2010 10:21 PM, Torri, Stephen CIV NSWCDD, W15 wrote:
>> From: cmake-bounces at cmake.org on behalf of Yifei Li
>> Sent: Tue 6/8/2010 4:15 PM
>> To: cmake at cmake.org
>> Subject: Re: [CMake] dependency problem
>>
>> Thank you for reply.
>>
>> I already tried that.  I think the problem was caused by 'find_library' in my plugin's CMakeLists.txt, because it failed to find 
>> MyLib
>>
>> I use a variable to hold the result of 'find_library'  and that variable is in turn used in target_link_libraries
> 
> Assuming both "MyLib" and the plugin exist in the same project I could do this
>  
> (CMakeLists.txt for MyLib)
> add_library ( MyLib SHARED ${SOURCE})
>  
> (CMakeLists.txt for plugin)
> add_dependencies ( MyLib )

Illegal as it would add a dependency *of* MyLib *on* nothing.

> add_library ( plugin SHARED ${SOURCE} )
> target_link_libraries ( plugin MyLib )
>  
> I don't see you needing to use find_library. That is intended to find a library external to the existing project. It should not be necessary to find a library internal to a project.

You even don't need ADD_DEPENDENCIES() in the plugins' CMakeLists.txt
files as TARGET_LINK_LIBRARIES() tracks such dependencies by itself.

Regards,

Michael


More information about the CMake mailing list