[CMake] global variable

klaas.holwerda kholwerd at xs4all.nl
Thu Sep 8 16:58:22 EDT 2005


Hi,

In the lattest beta i am trying to extend a variable created at the top 
level.

Like:

SET( APE "whatever" )

ADD_SUBDIRCTORY( NUT )

--------------- in NUT:

SET( APE ${APE} "but this gets lost at top" )

The variable only contain "whatever" and not what as added in the 
subdirectory.

I wonder what is the scope of a variable, and not only that, i also 
notice command that 
commands like INCLUDE_DIRECTORIES in some subdirectory, are not noticed 
at the top or other subdirectories at the same level.

Can someone explain what is the scope of commands in Cmake?
I looks like that it is the directory where it is in and all subdirectories?
Is there a way to make the scope of variables global? ( i tried CACHE , 
which did not help ).

I now went as far as writing stuff to a file in sube subdirectory, and 
reading it back from the file at a higher level directory. But i wonder 
if there is not  a better way to do this?

Thanks for some help,

Klaas















More information about the CMake mailing list