I used to have some code to do this inside cmake. Bill wouldn't let me put
it into the kitware repository (fair enough really.)
I don't have the code anymore, but it was fairly trivial to write.
Take the vector of libraries
convert it to a list.
it1 = list.end.
while (it1 != list.begin)
it2 = it1;
while (it2 != list.begin)
it3 = it2;
if (*it1 == *it3) list.erase (it3);
The tricky part was figuring out where to put it. I remember spending more
time stepping through CMake to figure out where to put the new code, than
writing and testing it. Having a quick look at the code, I'd guess
cmMakeFile::FinalPass(), but I'm not sure.
One alternative is to wait for the proper dependency analyser that Amitha
has said he will put into CMake.
> -----Original Message-----
> From: Wheeler, Fred (Research) [mailto:wheeler@...]
> Sent: Friday, May 10, 2002 2:23 PM
> To: 'vxl-users@...'; 'cmake@...'
> Subject: [Vxl-users] VXL/cmake cygwin build: link line -l option order
> VXL and CMake lists:
> I'm trying to get a clean VXL build with cygwin/gcc-2.95.3-5. Has
> anyone else done this? I'm having trouble with the link "-l" options
> and their order.
> It looks like on this system the link line library order is important.
> If lib B depends on lib A, then "-lA -lB" will not work, I have to use
> "-lB -lA". I seem to recall that is also a requirement on some hpux
> CMake seems to be emitting a "-l" option for each library only once.
> That would seem to be an improvement over the very long link lines of
> the past. However, it is now causing me grief.
> I have been able to fix most of these problems in VXL by swapping
> INCLUDE lines in various CMakeLists and CMakeListsLinks files. But,
> there are (or at least can be) situations where this will not work.
> An example of the problem is when a target needs libraries B and C,
> and adds them with CMakeListsLink files that in turn use
> LINK_LIBRARIES commands. Suppose both B and C in turn depend on
> library A. Then, without removing duplicates, cmake would emit "-lB
> -lA -lC -lA", but removing duplicates, cmake emits "-lB -lA -lC". The
> 2nd "-lA" is a duplicate, so it is removed. Now, C comes after A, so
> there are unresolved symbols at link time.
> If duplicates were removed from the right to the left, this would not
> be a problem.
> Does anyone know how to kludge cmake so no duplicates are eliminated?
> Any other comments/ideas?
> Fred Wheeler
> Fred Wheeler, GE CRD, KWC-303
> Phone: 518-387-7225 (GE Internal Dialcom: 8*833-7225)
> Fax: 518-387-4042 (GE Internal Dialcom: 8*833-4042)
> Have big pipes? SourceForge.net is looking for download
> mirrors. We supply
> the hardware. You get the recognition. Email Us:
> Vxl-users mailing list