[CMake] Help cmake to resolve link lines with multiple circular dependencies?

Alexandre.Feblot at thomsonreuters.com Alexandre.Feblot at thomsonreuters.com
Thu Apr 23 08:36:04 EDT 2009


Hi,

 

I have some code with multiple circular dependencies. I rely on the
transitive dependency mechanism to create the link line. Following is a
short example of libs which can't be resolved properly.

==> My question is: if there a way to help cmake create a working link
line.

 

In the example, each function is in a separate file:

-          lib1 contains files 

o        f1.c (defines function lib1f1)

o        f2.c (defines function lib1f2)

o        f3.c (defines function lib1f3)

-          lib2 contains file

o        f1.c (defines function lib2f1)

-          lib3 contains files 

o        f1.c (defines function lib3f1)

o        f2.c (defines function lib3f2)

 

And here is the call graph of these functions: main -> lib1f1 -> lib2f1
-> lib3f1 -> lib1f2 -> lib3f2 -> lib1f3

 

Using target_link_libraries(), I set that:

-          exe depends on lib1

-          lib1 depends on lib2, lib3

-          lib2 depends on lib3

-          lib3 depends on lib2

 

And the generated link line is : lib1 lib2 lib3 lib1 lib2 lib3.

 

Of course, this fails with an undefined symbol lib1f3 first declared in
lib3/f2.c.

 

So, is there a way to help cmake resolve this link line without changing
the lib1,2,3 code (because my project has too many of such circular
dependencies to make such corrections possible. (I'm still evaluating if
we can switch to our build system to cmake))

Thanks,

Alexandre 

 



This email was sent to you by Thomson Reuters, the global news and information company.
Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090423/232ed8a9/attachment-0001.htm>


More information about the CMake mailing list