[CMake] Linking archives in a sibling directory

Raymond Wan r.wan at aist.go.jp
Thu Dec 2 21:34:23 EST 2010


Hi Rolf,


On Thu, Dec 2, 2010 at 23:36, Rolf Eike Beer <eike at sf-mail.de> wrote:
> Let's say you have
>
> dirA, dirB, dirC
>
> dirA builds a lib
> dirB builds a lib that needs libA
> dirC builds a target that needs libA and libB
>
> Then you can't do
>
>
> libB/CMakeLists.txt
>  ADD_SUBDIRECTORY(../dirA dira)
>
> libB/CMakeLists.txt
>  ADD_SUBDIRECTORY(../dirA dira)
>  ADD_SUBDIRECTORY(../dirB dirb)
>
>
> CMakeLists.txt
>
> ADD_SUBDIRECTORY(dirA)
> ADD_SUBDIRECTORY(dirB)
> ADD_SUBDIRECTORY(dirC)


Yes -- that's exactly what I was trying to say.  Thank you for the example!

I suppose the default behavior of ADD_SUBDIRECTORY is understandable
since it is meant to catch duplicate names.  By this I mean that maybe
its aim was to catch these problems when they are caused by human
error.


> since dirA is included twice. We have a module for that:
>
> function (Add_Subdirectory_Once SUBDIRECTORY)
...


Thank you for this!  I presume by "We" you mean you and your
organization?  That is, this function isn't in CMake.

I'll give it a try and see if it solves my problems.  Thank you all
for your explanations!

Ray


More information about the CMake mailing list