[CMake] when are variables inherited?

Javier Gonzalez javierggt at yahoo.com
Wed Sep 26 11:27:44 EDT 2007


Sylvain Benner wrote:
>
>> I still don't understand when variables are inherited by subdirectories.
>> I see that if I define the variable using cmake -D then it is the same
>> in all subdirectories. I guess I could use an environment variable.
>> However, if I do something like:
>>
>> SET (FINITO_INSTALL_DIR /Users/jgonzalez/financial/finito/trunk CACHE
>> PATH "finito-dir")
>>
>> it is not inherited by subdirectories. What am I missing
> Hello,
>
> Which command do you use for subdirectories ?
> Be sure to use ADD_SUBDIRECTORY and not SUBDIRS which is an old
> command left in current release for compatibility purpose.
>
> The behavior of ADD_SUBDIRECTORY is that each CMakeLists.txt added
> with this command inherits from the variables set in the caller
> CMakeLists.txt.
>
> --Sylvain
>
>
hah! I see what happened. Obviously, the variable needs to be set
_before_ using ADD_SUBDIRECTORY (oops). For some reason I had it after.
Thanks anyway.

Javier


More information about the CMake mailing list