[CMake] return and break commands

Ken Martin ken.martin at kitware.com
Wed Jan 23 10:56:04 EST 2008


I just checked into CVS return and break commands for CMake. They work
pretty much how you would expect the usual C return and break commands to
work.  A couple quick notes:

1) Macros are like cpp macros (not functions), a return in a macro is no
different than an inline return.

2) return from a directory/file (as opposed to a function) will stop
processing that CMakeLists file and return control to the parent (whoever
called add_subdirectory) if there is a parent.

3) break works on foreach and while loops. A break inside an if/else clause
breaks you out of the enclosing foreach or while loop just like C. The same
idea holds for return statements inside an if/else/foreach/while, they
return you out of the current function or directory.

4) return invoked from an included file should stop processing the current
file and take you back to the point of the include command. (forgot to add a
test for this one, but really, what are the odds untested cases would have a
bug in them :) *kidding*

5) basically these commands should do something fairly intuitive

Give me a holler if there are problems.

Ken


Ken Martin PhD 
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971 





More information about the CMake mailing list