[CMake] return and break commands

Josef Karthauser joe.karthauser at geomerics.com
Fri Jan 25 04:49:16 EST 2008

What would be useful, would be to be able to interrupt the current
CMakeLists file, from within a macro.

The usage case would be:

  CMakeLists.txt (from a subdirectory):


	# normal stuff follows

The MY_CONFIG_MACRO() checks the environment, and determines whether the
current project is suitable, and causes interruption of the cmakelists
file if so.

In the plan you've just implemented one would have to do:


	# normal stuff follows

Which seems a bit message, as now the implementation of the local
configuration details needs to be explicit in each and every cmake file.
Can you consider not overloading the RETURN command and introducing a
separate command so that the two usage cases can be distinguished.  In
practice I think that it would be useful to both RETURN from a macro,
and EXIT the current CMakeLists.txt file within a macro.  You could make
RETURN == EXIT if called directly from a CMakeLists file (as opposed to
inside a macro).  That would provide maximum flexibility.



> -----Original Message-----
> From: cmake-bounces+joe.karthauser=geomerics.com at cmake.org
> [mailto:cmake-bounces+joe.karthauser=geomerics.com at cmake.org] On
> Of Ken Martin
> Sent: 23 January 2008 15:56
> To: cmake at cmake.org
> Subject: [CMake] return and break commands
> 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
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake

More information about the CMake mailing list