title: Cmake: how to delete old variables with a new build
body: <p>I am trying to configure my app with cmake, which depends on</p>
  <pre><code>cmake -DVERSION_TO_BUILD ../
  </code></pre>
  <p>In my CMakeList I wrote that checker</p>
  <pre><code>if (NOT VERSION_TO_BUILD)
      message(FATAL_ERROR &quot;Please, set VERSION_TO_BUILD&quot;)
  endif()
  </code></pre>
  <p>In first configure all works normally, but in the next time when I try to reconfigre like</p>
  <pre><code>cmake ../
  </code></pre>
  <p>When I configure my app without -DVERSION_TO_BUILD=1, cmake throws an error (as expected).
  After that, I configure an app with -DVERSION_TO_BUILD=1 and it does not give an error (as expected).
  However, when I go back to the first option without -DVERSION_TO_BUILD=1 it does not give an error. I checked it by calling message and found that it exists.
  <br>
  I found out that cmake saved VERSION_TO_BUILD variable. So my checker doesn't work correctly.<br></p>
  <p>Of course, I can't use set in CMakeList because VERSION_TO_BUILD is external dependency.<br>
  How can I fix this so that I don't delete the cmake folder?</p>