[CMake] Problem while setting variables in CMakeCache

Stefan Köhnen stefan.khnen at googlemail.com
Mon Sep 6 14:20:44 EDT 2010


Ah, okay.

Thanks for your fast reply.

Is there a way to change the value in the cache?

Stefan

2010/9/6 Alexander Neundorf <neundorf at kde.org>:
> On Monday 06 September 2010, Stefan Köhnen wrote:
>> Hello,
>>
>> I am trying to set a variable that appears in CMakeCache. I made this
>> small example to show what I am trying to do.
>>
>> CMakeLists.txt:
>> PROJECT(CMakeTest)
>>
>> SET(VAR_FOR_TEST "firstValue" CACHE STRING "Just for testing")
>>
>> set(VAR_FOR_TEST "secondValue")
>>
>> MESSAGE (${VAR_FOR_TEST})
>>
>>
>> When I run cmake from the build-folder I get the message
>> "secondValue", but when I look in the CMakeCache.txt-file I see this:
>>
>> //Just for testing
>> VAR_FOR_TEST:STRING=firstValue
>>
>> Why is VAR_FOR_TEST set to firstValue, there is probably something I
>> missed in my CMakeLists.txt but I found no example for this kind of
>> problem on the Internet.
>
> The first set() stores the value in the cache. The second set() create
> basically a second variable with the same name, which is not in the cache,
> and which shadows the one from the cache.
>
> Alex
>


More information about the CMake mailing list