[CMake] global variable vs cache variable
Michael Wild
themiwi at gmail.com
Tue Nov 22 06:19:42 EST 2011
On 11/22/2011 11:51 AM, t m wrote:
> Hi Community,
>
> I could not found any other possibilites to set some global variable
> than using a cache variable. Even if this is not nice sometimes you
> need to have a global variable.
> So I would like to ask about advice in this area:
>
> 1) Is this the real use case for cache, so to use it as a global
> variables container. In my understanding this is something that is
> intended to use if you would like to save
> some values between separate calls of the cmake.
>
> 2) Is there any performance issue with using of cache, I/O, etc? What
> is better way use PARENT_SCOPE in the loop to forward the variable to
> the upper level scope or just CMakeCache.
>
> Looking for advise,
> Best regards, T. Majchrowski
Use the cache only if the values need to be persistent. Otherwise I
recommend using a GLOBAL property. See set_property() and get_property().
Michael
More information about the CMake
mailing list