[CMake] target_link_libraries fails dependencies

Andrea Galeazzi galeazzi at korg.it
Thu Nov 15 04:42:29 EST 2012


Il 14/11/2012 13.01, Andreas Pakulat ha scritto:
> Hi,
>
> On Wed, Nov 14, 2012 at 12:34 PM, Andrea Galeazzi <galeazzi at korg.it> wrote:
>> I'm using cmake_policy(SET CMP0015 NEW) to link external libraries (I don't
>> have the sources of them) in order to avoid to specify the absolute path of
>> each library. So I wrote the following commands:
>> link_directories(path1 path2 ...)
>> target_link_libraries(${my_TARGET_NAME} lib1 lib2)
>>
>> but when lib1 or lib2 changes, my_TARGET_NAME doesn't rebuild the
>> executable. On the other hand if I use the absolute path in
>> target_link_libraries (path1/lib1.a) everything works fine.
>> Is this behavior a bug of CMake or is not possible to detect this kind of
>> dependencies at all?
> That is not a bug in CMake. When you specify only library names CMake
> cannot setup dependencies in the generated makefiles (or whatever
> generator you use), since it has no clue where the library file is as
> you leave the knowledge about that to the linker. So you either need
> to specify the absolute path to lib1 and lib2 or trigger a clean build
> of the target when the libs change.
>
> Since it seems you already setup the paths to the libraries via
> link_directories it should actually be rather easy for you to drop
> that and simply use the absolute path in target_link_libraries I'd
> say.
>
> Andreas
>
You're definitely right.

-- 
korg Firma

*KORG ITALY SPA*

*Via Cagiata, 85 -- 60027 Osimo (AN) - ITALY*

*Ph. +39 071 727161 -Fax   +39 071 7231228*

*P.IVA e Cod. fiscale IT01460580424*


  *Soggetta al controllo della Società KORG Inc. - Giappone*


  *Reg. Imprese di n. 212056/1996 del 23/12/96*


  *REA di Ancona al n. 133105 del 06/12/96*


  *Capitale sociale Euro 814.253,16  i.v.*

Ai sensi del D.Lgs. 30 giugno 2003, n. 196, "Codice in materia di 
protezione dei dati personali" si precisa che le informazioni contenute 
nel messaggio sono riservate e destinate esclusivamente alla persona od 
organizzazione sopra indicata. A chi legge il presente avviso - se non è 
l'effettivo destinatario, o un dipendente, o la persona responsabile 
della consegna del messaggio - si notifica che sono proibite copie, 
distribuzione o divulgazione di quanto in esso contenuto (C.P. 616). Se 
questo messaggio Vi è pervenuto per errore, Vi preghiamo di informarci 
immediatamente, di non leggerlo e di distruggerlo. Grazie.

/According to Legislative Decree n. 196 of 30 June 2003 about "Personal 
Data Protection Code" we point out that the information contained in 
this message may be privileged and confidential and is intended only for 
the use of the individual entity named above. If the reader of this 
message is not the intended recipient, or an employee or agent 
responsible for delivering this message to the intended recipient, you 
are hereby notified that any dissemination, distribution, or copying of 
this message is strictly prohibited. If you have received this message 
in error, please notify us immediately and destroy the original message. 
//Thank you./

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121115/da7191d3/attachment-0001.htm>


More information about the CMake mailing list