[CMake] some comments on the LIST command
Gaetan Lehmann
gaetan.lehmann at jouy.inra.fr
Thu May 11 16:54:49 EDT 2006
Hi,
We have implemented for WrapITK some list functions in pure cmake. It would be
nice to be able to replace them by native functions. Some of them are already
there (SORT for example), but some are missing:
- LIST(UNIQUE <list>) remove all the duplicate items in the list.
- LIST(INTERSECT <list> <element> [<element> ...]) compute the intersection
of the list and the list of element given in parameter. I think the output
variable should not contain any duplicate item, but it should be discussed.
- LIST(HAS_ITEM <list> <item> <output variable>) set output variable to ON if
the item is in the list, and to OFF otherwise.
Also, I'm surprised to see that the LIST commands always modify the list, and
does not produce a new one. It is definitively not always the desired
behavior. It is not a important issue - some macro can easily be created to
workaround that.
Finally, I think REMOVE and REMOVE_ITEM should be swapped - for me, the item
is what is removed from the list, not its index. Currently, we have:
LIST(REMOVE <variable> <value> [<value> ...])
LIST(REMOVE_ITEM <variable> <index> [<index> ...])
Gaetan
On Thursday 11 May 2006 21:43, Alexander Neundorf wrote:
> Hi,
>
> > Von: Andy Cedilnik <andy.cedilnik at kitware.com>
> >
> > Hi Alex,
> >
> > Alexander Neundorf wrote:
> > >yesterday I played a bit with the new LIST command in 2.4.1, and here
>
> are
>
> > >some comments:
>
> ...
>
> > >-in the docs the list variable is sometimes called LIST and sometimes
> > >called VAR
> >
> > They should all be really a list variable. So, you cannot say:
> >
> > LIST(LENGTH "foo;bar" var)
> >
> > and expect to get 2.
>
> While this would be also nice, this isn't what I meant.
> I just noticed that in the documentation the list variable is sometimes
> called "list" and sometimes called "variable":
> LIST(LENGTH <list> <output variable>)
> vs.
> LIST(REVERSE <variable>)
>
> > >-why does an access beyond the end of the list fail with a cmake
>
> error ?
>
> > >I would have expected to get an empty or FALSE or NOTFOUND value. This
> > >would make using it easier
> >
> > Should it fail gracefully? What should be the indicator?
>
> Returning a "false"-value, e.g. "ITEM_NOTFOUND" or something like this.
>
> > >-the LIST command does not work on ARGN. Is this intentional ?
> >
> > ARGN is special for now because of the way macros are handled. To use
>
> it
>
> > do this:
> >
> > SET(myarray ${ARGN})
> > LIST(.... myarray ...)
>
> Yes, I did this. But it felt like a workaround for something which should
> actually work.
>
> > > -why is LIST( SET ...) not called LIST(APPEND ... ) ?
> >
> > I added APPEND. I may take LIST(SET out.
> >
> > > -is LIST(SET mySrcs foo.cpp) faster than SET(mySrcs ${mySrcs}
>
> foo.cpp) ?
>
> > List SET/APPEND appends, while SET justs sets to the value.
>
> Ok, I'll do some benchmarking.
>
> Bye
> Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/cmake/attachments/20060511/392c9311/attachment-0001.pgp
More information about the CMake
mailing list