[CMake] Problem while setting variables in CMakeCache

Stefan Köhnen stefan.khnen at googlemail.com
Mon Sep 6 12:33:57 EDT 2010


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.

My CMake version is 2.6-patch 3, but I think the problem is my code not CMake.


Thanks for your help,

Stefan Köhnen


More information about the CMake mailing list