[CMake] Marking a library dependency from within a library.

Pau Garcia i Quiles pgquiles at elpauer.org
Fri Nov 30 14:18:53 EST 2007


Quoting Ilya Shvetsov <chvetsov at kranx.com>:

What you are asking for is essentially what FIND_PACKAGE provides.  
Create your own FindlibB.cmake which sets libB_FOUND to true and  
libB_LIBRARY to the filename (i. e. /usr/lib/libB.so or whatever),  
then TARGET_LINK_LIBRARIES(execC libA ${libB_LIBRARY})

>> I am not sure if Josef Karthauser was referring to such a   
>> situation. This case
>> occurs quite often in my projects and so far I found no way how to fomulate
>> these dependencies in an elegant way. Anyone who can help me (and probably
>> Josef Karthauser)?
>>
>
> I would like also to have an explanation about this.
>
> -- 
> Ilya Shvetsov (mailto:chvetsov at kranx.com)
> Lead Programmer
> KranX Productions (http://kranx.com/)
>
>
> On Thu, 18 Oct 2007 15:10:35 +0300, Christian Hoffmann
> <christian_hoffmann at gmx.net> wrote:
>
>> On Thursday 18 October 2007 13:47, Bill Hoffman wrote:
>>> Josef Karthauser wrote:
>>>> I have a library (libA), which depends upon another library (libB) for
>>>> its implementation.    I also have an executable (execC) which uses
>>>> LibA.  Is there an easy way of getting LibB added to the list of
>>>> dependencies, so what when I do
>>>>
>>>>
>>>>
>>>>   Add_Executable(exeC)
>>>>
>>>>   Target_Link_Libraries(exeC libA)
>>>
>>> Yes, where you create libA, you add this:
>>>
>>> target_link_libraries(libA libB)
>>>
>>> CMake will automatically chain.
>> Hi,
>>
>> this is the obvious answer if both library a built within your own project.
>> However, it is unclear to me how to set such link dependencies between libs
>> NOT being part of the project. In that case, your proposed solution would
>> lead to
>>
>> CMake Error: Attempt to add link library "libB" to target "libA"   
>> which is not
>> built by this project.
>>
>> I am not sure if Josef Karthauser was referring to such a   
>> situation. This case
>> occurs quite often in my projects and so far I found no way how to fomulate
>> these dependencies in an elegant way. Anyone who can help me (and probably
>> Josef Karthauser)?
>>
>> Best regards
>>
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake



-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)



More information about the CMake mailing list