[CMake] Regarding option for regenerating CMakeCache everytime we do cmake

Nils Gladitz nilsgladitz at gmail.com
Mon Mar 24 06:39:15 EDT 2014


On 03/24/2014 11:01 AM, Devyani Godbole wrote:
> Hi ,
> I am getting a problem wherein the if I add the flag say -DWITH_DATE=1
> and do a cmake I get it enabled. But now if I do not use this flag and
> again do cmake , it still remains DEFINED i.e. it is still present in
> CMakeCache.
>
> I do not want it to be DEFINED if I have not specified it in cmake
> command line. i.e. I want the CMakeCache to be rebuilt everytime I do a
> cmake.

-D sets a cache variable. I don't think regular variables can be set 
from the command line.

You could replace (set() with FORCE) or remove (unset() with CACHE) the 
existing cache variable from within your CMakeLists.txt every time it is 
set but that will probably break what ever logic you have associated 
with the variable in implicit cmake runs.

Would an environment variable be an option?
They can be accessed from within cmake with $ENV{NAME}.

I assume you would want to keep the variable value intact for implicit runs.

For that case an environment variable scoped to a configure/build 
session could work?

Nils


More information about the CMake mailing list