[cmake-developers] Tools for handling cross project dependencies

Egor Pugin egor.pugin at gmail.com
Mon Oct 2 12:06:02 EDT 2017


Sorry, maybe I did not understand you correctly, but why do you need
some order of 'add_subdirectory'?
Cppan knows from config (yaml) files what deps must be included and
just adds them one by one. If they're already in the tree, include
guard prevents second use.
One rule is not to have cyclic deps.

> In summary (correct me if I am wrong) what this does is (in some pseudo code):

Correct pseudo code for cppan:
---
if (TARGET t1)
  return

include(d1) # include file has i. guard
include(d2) # cannot use add_subdirectory directly
...

declare t1
target_deps t1 d1 d2 ...
---

On 2 October 2017 at 16:10, Raffi Enficiaud
<raffi.enficiaud at mines-paris.org> wrote:
> Le 27.09.17 à 19:10, Egor Pugin a écrit :
>>>
>>> The idea is to include several "packages" (one package ~ one project in
>>> Boost) and make those available to the build, exactly as for a regular
>>> CMakeLists.txt that adds several directories or subprojects through a
>>> sequence of calls to "add_directories".
>>> However, the difference here is that "packages" have inter-dependencies,
>>> and the order of the "add_directories" should honor those dependencies.
>>
>>
>> I solved the issue of including several dirs (via 'add_directories')
>> using guards 'if (TARGET name); return(); endif()' in my pkg manager.
>> See boost libraries there: https://cppan.org/search?q=boost
>> Each library can be included to project separately with autoincluding
>> required deps for it.
>
>
> Hi,
>
> Thank you for your answer. What you did with CPAN is wonderful, but I think
> this much more than what my humble scripts are trying to address.
>
> Also the guard mechanism does not really address the issue of ordering the
> add_directories in some topological order. In particular, you guard because
> you do not want to declare several times the same target, but it does not
> tell when to include any other dependencies your target may have.
>
> In summary (correct me if I am wrong) what this does is (in some pseudo
> code):
>
> ---------
> if(target1, target2 ... already defined)
>   return
>
> declare target1, target2 ...
> target_dependencies target1, target1.1, target1.2 ...
> target_dependencies target2, target2.1, target2.2 ...
> ---------
>
> but it does not tell when to declare target1.1, target1.2 ... and this
> knowledge should be encoded somewhere else in your scripts.
>
> Best,
> Raffi
>
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake-developers



-- 
Egor Pugin


More information about the cmake-developers mailing list