[CMake] Acces macro/functions to subfolders

Marcel Loose loose at astron.nl
Thu Dec 17 05:21:50 EST 2009


On Wed, 2009-12-16 at 09:28 -0800, Tyler Roscoe wrote:
> On Wed, Dec 16, 2009 at 05:55:54PM +0100, Olivier Pierard wrote:
> > In order to be able to use a macro/function from several sub-folders, I
> > would like to define it only once in the main CMakeLists.txt.  However,
> > after some basic tests, It seems impossible to call this macro/function
> > from subfolders.  Is is possible to do it ?
> 
> It works for me.
> 
> > By the way, what's the basic difference between macro/function in cmake
> > ?  Related to preprocessing like in C/C++ ?  What's the advantage of
> > distinguish them here ?
> 
> The details are in the docs, though you have to read carefully to
> notice. I think the biggest difference is that the contents of a macro
> are dropped in, as though with #define. Functions are an actual function
> call and functions have their own scope.
> 
> tyler

Another important difference is that, for functions, ARGV and ARGN and
ARGVn (n=1..) are real variables that have local scope.

Best regards,
Marcel Loose.






More information about the CMake mailing list