[CMake] Build the dependencies tree of an executable

Glenn Coombs glenn.coombs at gmail.com
Fri Jul 22 18:25:59 EDT 2011


Have you tried using target_link_libraries(A D E F) in A/Deps.cmake instead
of add_dependencies ?  I think that the add_dependencies command only
enforces a build order between targets.  I don't think it actually adds
libraries to the link line.

On 18 July 2011 17:54, 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/44003f47/attachment-0001.htm>


More information about the CMake mailing list