target_link_libraries fails dependencies

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

target_link_libraries fails dependencies

Andrea Galeazzi
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?
--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: target_link_libraries fails dependencies

Andreas Pakulat-2
Hi,

On Wed, Nov 14, 2012 at 12:34 PM, Andrea Galeazzi <[hidden email]> 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
--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: target_link_libraries fails dependencies

Andrea Galeazzi
Il 14/11/2012 13.01, Andreas Pakulat ha scritto:
Hi,

On Wed, Nov 14, 2012 at 12:34 PM, Andrea Galeazzi [hidden email] 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.

 

 


--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: target_link_libraries fails dependencies

Alexander Neundorf-3
In reply to this post by Andrea Galeazzi
On Wednesday 14 November 2012, Andrea Galeazzi 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)

Whenever possible, you should use absolute paths to libraries.

CMP0015 actually does not change this.
The only thing it does, is that if you use a relative path, e.g. "mylibs/",
then with CMP0015 set to OLD, this will be interpreted as
${CMAKE_CURRENT_BINARY_DIR}/mylibs/, while with CMOP0015 set to NEW, it will
be interpreted as ${CMAKE_CURRENT_SOURCE_DIR}/mylibs/

Alex
--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake