<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="margin: 0px;">Hello,</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">First post here.  Sorry if its too long.  Simply trying to be as clear as I can be.</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">I am trying to make sense of the various ways to set a variable and how one can shadow the other.  Long story short, I am trying to get the following behaviour for a variable in a script:</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">  1 - check if MYVAR exists</div><div id="bloop_customfont" style="margin: 0px;">          1.1 - If it does, test its validity and set a second variable named MYVAR_VALID to TRUE or FALSE</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">  2 - if MYVAR does not exist or if MYVAR_VALID is FALSE, inspect system for information and set MYVAR (with FORCE in the cache) and MYVAR_VALID (not in cache, but does not seem to make a difference).</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">Hope this is written clearly enough to be understood.  Sorry, english is not my first language.  Anyhow, I get the following behaviour easily except in one case, which is the reason for my question.  These are the cases I have tested :</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">- Start with empty cache and call ccmake.  Then, MYVAR does not exist.  My script inspects the system, sets the value, sets MYVAR_VALID to TRUE and stops.  On successive runs, the variable is defined and valid, so the system is not inspected again.  Everything is fine.</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">- Start with empty cache.  Run it once, but can’t find a valid entry (or find a wrong one somehow, but that’s practically impossible since the code in my script to inspect the system and to test the variable are basically the same.  I digress, sorry).  Set MYVAR_VALID to FALSE.  User can set the value to a valid one and on next run, the script will set MYVAR_VALID to TRUE and then, we are back to variable defined and valid.  Everything is fine.</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">- Start with "non-empty cache" because ccmake (or cmake) is called with -DMYVAR:PATH="/Users/“, for instance.  If the value set on command line is fine, then MYVAR_VALID will be set to TRUE on the first run and no system inspection is necessary.  The value is now set and valid.  Everything is fine.</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">Now, for my problem :</div><div id="bloop_customfont" style="margin: 0px;"><div id="bloop_customfont" style="margin: 0px;">- Start with "non-empty cache" because ccmake (or cmake) is called with -DMYVAR:PATH="/Users/“, for instance.  But this time, the value is not a valid one.  Then, the variable is defined but not valid.  So on the first run, the script will inspect the system.  If it can find a valid value, I would like my script to override the variable with the valid one. Then, set to valid and so on and so forth...</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">I have not been able to do this.  I can find the correct value, I can set the new value, but it is not used.  I mean by that that I have inspected the CMakeCache.txt file and when I call ccmake, the cache contains the value set on the command line.  Then, I launch my cmake script and output the values of MYVAR and MYVAR_VALID and they are respectively the one of the command line and FALSE.  Then, I find the correct value for MYVAR and try and set it.  When I inspect the cache, it seems the value has effectively been overwritten.  But when I try to output the new variables, it seems to remain stuck at the value provided on the command line.  I have tried using unset( MYVAR ) in scope, in the parent scope and in the CACHE before setting the new value.  Still, the old value is outputted.  The only way to get the new value is to close ccmake and launch it again.</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">Now if you’re still following (I am sorry, a bit complicated to follow I’m afraid, trying to be thourough), I guess my question is:</div><div id="bloop_customfont" style="margin: 0px;">Is this normal behaviour ?   Is there something I am missing or is it simply how CMake works and I should simply tell my users to either initially set the right value or restart their ccmake.</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">I haven’t tested this on Windows with CMake-GUI yet.  I might have time to do it a little later.</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">Anyhow, if anybody has the courage to read through my mail and try and help me, thanks a million.</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;">Ghyslain</div><div><br></div><div><br></div></div></body></html>