[CMake] doing simple math in cmake or useless foreach( RANGE )

Nicolas Desprès nicolas.despres at gmail.com
Tue May 19 22:38:05 EDT 2009


On Tue, May 19, 2009 at 6:29 PM, Hendrik Sattler
<post at hendrik-sattler.de> wrote:

>
> If that's not present, I do not understand how
> LIST( LENGTH MYLIST COUNT )
> FOREACH ( index RANGE ${COUNT} )
> list ( GET MYLIST ${index} entry )
> ....
>
> will address non-present indexes in the list. I would the above statement
> cover the range from 0 to COUNT-1 but it also cover COUNT itself like said in
> the documentation. Does that actually make sense as the variable in the
> documentation is called "total" but the loop count is "total+1"?
>

I also experienced this problem and I don't like this behavior. I'm
more use to the traditional

for (i = 0; i < n; ++i)

instead of <=


-- 
Nicolas Desprès


More information about the CMake mailing list