Specifying the lib4 dependency in the exe? But what about dependencies order in the link line? In my example, lib4-A or lib4-B must appear after lib3, if I want lib4 symbols required by lib3 to be added. In your solution, lib4 might as well be added by cmake just after lib1 and before lib3, which will result in a link failure. More over, the executable is even not supposed to know that it depends on lib4. It just knows it depends on lib1, which knows it depends on lib3, which knows it depends on lib4. (I gave a simple example, but the real project is a large one with many dependencies, including circular ones, and we don't want / can't easily know all libX-A/B that must be added to every executable)
Also, tell me if I'm wrong, but I don't see how the if-then-else solution could be used: the build occurs in a single project which builds all libraries and executables. That means that lib3 must depend on lib4-A or lib4-B according to the executable we link. Using it-then-else would only add a dependency to one the lib4 version, and that could not be changed afterwards when linking my binaries: for some of them, lib3 must depend on lib4-A, and for some others, the same lib3 must then depend on lib4-B. Regards, Alexandre -----Original Message----- From: Michael Wild [mailto:[email protected]] Sent: Tuesday, 24 March 2009 13:43 To: Alexandre Feblot Cc: Cmake Mailing List Subject: Re: [CMake] Feature request: generic (config-like) selector on target_link_libraries On 24. Mar, 2009, at 12:30, Alexandre Feblot wrote: > > Dependency graph example: "->" means "depends on" > > exe1-A -> lib1 -> lib3 -> lib4-A -> lib5 -> lib7 > exe1-B -> lib1 -> lib3 -> lib4-B -> lib6 -> lib8 > exe2-A -> lib2 -> lib3 -> lib4-A -> lib5 -> lib7 > exe2-B -> lib2 -> lib3 -> lib4-B -> lib6 -> lib8 > >> I'd like to keep using the standard cmake mechanism of dependency > description in which every lib only defines on which other libs it > depends, and let cmake compute the final link line. > I also fail to see why this would be a problem, especially if all libraries are static, as you say (Static libraries are simply archives of object files, so no symbols have to be resolved while they are created since no linking happens). Simply don't have lib3 depend on any of the lib4-X, but add those lib4-X directly to the link-commands of exeY-X. E.g.: # Establish dependencies between static libraries. target_link_libraries( lib1 lib3 ) target_link_libraries( lib2 lib3 ) target_link_libraries( lib5 lib7 ) target_link_libraries( lib6 lib8 ) target_link_libraries( lib4-A lib5 ) target_link_libraries( lib4-B lib6 ) # Link the executables target_link_libraries( exe1-A lib1 lib4-A ) target_link_libraries( exe1-B lib1 lib4-B ) target_link_libraries( exe2-A lib2 lib4-A ) target_link_libraries( exe2-B lib2 lib4-B ) Hope this helps Michael 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. _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at 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 Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
