Breaking a foreach loop
Brad King
brad.king at kitware.com
Tue Apr 18 16:20:03 CEST 2006
Pino Toscano wrote:
> Hello,
>
> imagine I'm iterating using a foreach() like this:
> set(MY_OPTS "foo bar etc")
> foreach(OPT ${MY_OPTS})
> # do something ...
> endforeach(OPT ${MY_OPTS})
>
> is there a way to break the iteration, just like a break in C?
>
> Whether it exist, does it break even nested foreach()?
This is not possible, but you can simulate it yourself:
SET(OPT_DONE 0)
foreach(opt ${MY_OPTS})
if(NOT OPT_DONE)
#...code...
if(..need to break..)
set(OPT_DONE 1)
endif(..need to break..)
endif(NOT OPT_DONE)
endforeach(opt
-Brad
More information about the Kde-buildsystem
mailing list