[CMake] Transitive include and link libraries on imported targets ?

Dvir Yitzchaki Dvir.Yitzchaki at ceva-dsp.com
Thu Apr 6 00:11:46 EDT 2017


target_link_libraries(B INTERFACE A)

Regards,
Dvir

From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of David Jobet
Sent: Wednesday, April 5, 2017 18:34
To: cmake at cmake.org
Subject: [CMake] Transitive include and link libraries on imported targets ?

Hello,

Let's say I build some external libs A and B with B depending on A.
B and A do not use cmake, so I build them and install them in a 3rdparty directory. I now have access to includes and libs.
I then create some cmake file to describe those libs so I can use them in my project :
Add_library(A_imported STATIC imported)
Set_property(TARGET A_imported APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES 3rdparty/include/A)
Set_property(TARGET A_imported APPEND PROPERTY IMPORTED_LOCATION 3rdparty/libs/libA.a)
Add_library(A INTERFACE)
Target_link_library(A INTERFACE A_imported)

Same thing for B

Now let's say I create a top-level target T that depends on B. Compilation might fail because B might include files from A and A is currently not a dependency of T.

I can fix it in 2 ways :
1- add A as a dependency of T, but I will need to do it on all my Ts
2- somehow make B have transitive dependencies for include and link on A. That would be my prefered choice... But I don't know how to do it.

Is it possible ? How ?

Tx for your help.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170406/85aa434b/attachment-0001.html>


More information about the CMake mailing list