[CMake] function vs macro

Bill Hoffman bill.hoffman at kitware.com
Tue Mar 3 22:07:43 EST 2009


Michael Jackson wrote:
> The subtle difference is this line from the "macro" help section:
> 
> Note that the parameters to a macro and values such as ARGN are not 
> variables in the usual CMake sense. They are string replacements much 
> like the c preprocessor would do with a macro. If you want true CMake 
> variables you should look at the function command.
> 
I should update this page to include functions and macros:
http://www.cmake.org/Wiki/CMake/Language_Syntax

The big difference is that functions have actual scope.   I guess that 
is missing from here:

http://www.cmake.org/cmake/help/cmake2.6docs.html#command:function

The scope issue is covered here:

http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set

-Bill


More information about the CMake mailing list