[Cmake] Looping over numbers

Andy Cedilnik andy.cedilnik at kitware.com
Tue Feb 4 11:57:58 EST 2003


Hi John,

How about a command RANGE with syntax:

RANGE(VARIABLE [START] END [INCREMENT])

Then you would say:

RANGE(var 1 20)
FOREACH(testnumber ${var})
...

For that you do not have to add new syntax.
Also, it can be done using loaded command.

			Andy

On Tue, 2003-02-04 at 11:43, John Biddiscombe wrote:
> Hi again,
> 
> Is there an easier way to loop over numbers than this
> 
>   FOREACH (testnumber 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
> 20)
>     ADD_TEST( 
>       # name of the test as seen on the dashboard	
>       TestPetBodySegmentation${testnumber}
>         # the executable to run 
>         ${EXECUTABLE_OUTPUT_PATH}/TestPetBodySegmentation.exe 
>           # args
>           "Test Case ${testnumber}/test_case_${testnumber}" 
>           "Test Case ${testnumber}/test_case_${testnumber}_info.txt"
>           "Test Case ${testnumber}/test_case_${testnumber}_baseline"
>     )
>   ENDFOREACH (testnumber) 
> 
> It works fine, but is there a
> 
>   FOREACH (testnumber {1..20} )
> 
> Type syntax I can use? If not shall I have a go at adding one?





More information about the CMake mailing list