[CMake] Build the dependencies tree of an executable

Yuri Timenkov yuri at timenkov.ru
Fri Jul 22 11:52:02 EDT 2011


Hi Marco,

I think target_link_libraries and add_dependencies are not applicable to
 imported targets. You should set IMPORTED_LINK_INTERFACE_LIBRARIES property
instead. I don't remember exactly, but I solved similar problem.

You can also try creating sample project with dependent static libraries
(you even don't need to compile it), and then export dependencies with
export(TARGETS) commands, and see what code CMake will generate.

Best wishes,
Yuri

On Mon, Jul 18, 2011 at 8:54 PM, Marco Corvo <marco.corvo at pd.infn.it> wrote:

> Hi all,
>
> I'm facing the following problem trying to generate the dependencies tree
> of an executable. I have a working area
>
> /path/to/my/working/area/**MyPackage
>
> with, say, one executable I want to build. The relevant CMakeLists.txt line
> is something like:
>
> add_executable(App src/App.cc)
> target_link_libraries(App A B C D)
>
> now these libs (A B C D) are already installed somewhere and they depend on
> other libraries of my software release. Say they're under
>
> /path/to/sw/release/X.Y.Z/lib/**arch/libA.a
> /path/to/sw/release/X.Y.Z/lib/**arch/libB.a
> /path/to/sw/release/X.Y.Z/lib/**arch/libC.a
> /path/to/sw/release/X.Y.Z/lib/**arch/libD.a
> /path/to/sw/release/X.Y.Z/lib/**arch/libE.a
>
> ...
>
> and that A depends on D, E and F. When I run my build, cmake only finds
> that my App has A, B, C and D as dependencies, while actually these
> libraries have also their own dependencies.
>
> I tried to add a .cmake file to each package in the release area
>
> /path/to/sw/release/X.Y.Z/**packageA/Deps.cmake
> /path/to/sw/release/X.Y.Z/**packageB/Deps.cmake
> /path/to/sw/release/X.Y.Z/**packageD/Deps.cmake
>
> with
>
> add_library(A STATIC IMPORTED)
> add_dependencies(A D E F...)
>
> which is "include"ed with my CmakeLists.txt file in order to let cmake know
> that when I build App it depends on A, B, C D _and_ A itself depends in his
> turn on D, E and F. This should create a complete dependencies tree for my
> App.
>
> I know that add_dependencies gives "Adding dependency to non-existent
> target" with cmake version before 2.8.4 if the target is IMPORTED while with
> 2.8.4/5 on a Scientific Linux 5 I'm getting a seg fault with the add_dep
> directive.
>
> Is this nevertheless the way to solve this problem? Are there other ways to
> build the dependencies tree of an executable which depends directly on some
> libs and indirectly on some other ones? Consider that I build static
> libraries, so I need to have the full list of libraries when linking the
> executable.
>
> Thanks in advance for your help.
>
> Cheers
>
> Marco
>
> --
> Marco Corvo
> SuperB experiment
> CNRS - Orsay
> c/o INFN - Padova
> ______________________________**_________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/**
> opensource/opensource.html<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<http://www.cmake.org/Wiki/CMake_FAQ>
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/**listinfo/cmake<http://www.cmake.org/mailman/listinfo/cmake>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110722/2b766591/attachment.htm>


More information about the CMake mailing list