<p>Use something like<br>
SET (GUI ${GUI} CACHE BOOL &quot;description&quot;)<br>
To put proper initial value from command line into cache. It won&#39;t be overwritten on the second run.</p>
<p>On Jul 1, 2011 2:02 PM, &quot;pellegrini&quot; &lt;<a href="mailto:pellegrini@ill.fr">pellegrini@ill.fr</a>&gt; wrote:<br type="attribution">&gt; Hello everybody,<br>&gt; <br>&gt; there is a behaviour I do not understand when using cmake with -D option.<br>
&gt; <br>&gt; In my project I defined a few CACHE variables. One of them is GUI to <br>&gt; specify whether or not my project should be<br>&gt; built with graphical library support.<br>&gt; <br>&gt; So in my main CMakeLists.txt I wrote something like:<br>
&gt; <br>&gt; SET(GUI FALSE CACHE BOOL &quot;do the build in GUI mode&quot;)<br>&gt; PROJECT(crysfml Fortran)<br>&gt; ...<br>&gt; <br>&gt; When launching cmake with:<br>&gt; cmake -G &quot;NMake Makefiles&quot; -D CMAKE_Fortran_COMPILER=ifort -D GUI=TRUE <br>
&gt; ..\..\.<br>&gt; <br>&gt; I always get the following message<br>&gt; <br>&gt; #################################################################<br>&gt; GUI VALUE =  TRUE<br>&gt; -- Configuring done<br>&gt; You have changed variables that require your cache to be deleted.<br>
&gt; Configure will be re-run and you may have to reset some variables.<br>&gt; The following variables have changed:<br>&gt; CMAKE_Fortran_COMPILER= ifort<br>&gt; <br>&gt; -- The Fortran compiler identification is Intel<br>
&gt; -- Check for working Fortran compiler: <br>&gt; C:/Intel/Compiler/11.1/054/bin/ia32/ifort.exe<br>&gt; -- Check for working Fortran compiler: <br>&gt; C:/Intel/Compiler/11.1/054/bin/ia32/ifort.exe  -- works<br>&gt; -- Detecting Fortran compiler ABI info<br>
&gt; -- Detecting Fortran compiler ABI info - done<br>&gt; -- Checking whether C:/Intel/Compiler/11.1/054/bin/ia32/ifort.exe <br>&gt; supports Fortran 90<br>&gt; -- Checking whether C:/Intel/Compiler/11.1/054/bin/ia32/ifort.exe <br>
&gt; supports Fortran 90 -- yes<br>&gt; GUI VALUE = FALSE<br>&gt; -- Configuring done<br>&gt; -- Generating done<br>&gt; -- Build files have been written to: <br>&gt; C:/Datas/Eclipse/workspace/crysfml/build/ifort_release_win<br>
&gt; #################################################################<br>&gt; <br>&gt; and the worse it that when deleting the cache and rebuilding it, the GUI <br>&gt; variable is switched to FALSE as you can see in the two MESSAGE commands <br>
&gt; I put in my code (GUI VALUE =). Though, I would tend to think that the <br>&gt; -D command should have the last word.<br>&gt; <br>&gt; There should be something I completely missed.<br>&gt; <br>&gt; thanks a lot<br>&gt; <br>
&gt; see you<br>&gt; <br>&gt; Eric<br>&gt; <br>&gt; <br>&gt; -- <br>&gt; Eric Pellegrini<br>&gt; Calcul Scientifique<br>&gt; Institut Laue-Langevin<br>&gt; Grenoble, France<br>&gt; <br>&gt; _______________________________________________<br>
&gt; Powered by <a href="http://www.kitware.com">www.kitware.com</a><br>&gt; <br>&gt; Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br>
&gt; <br>&gt; Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a><br>&gt; <br>&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.cmake.org/mailman/listinfo/cmake">http://www.cmake.org/mailman/listinfo/cmake</a><br></p>