<div dir="ltr"><div dir="ltr"><br><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">Le mar. 27 nov. 2018 à 14:50, Mario Emmenlauer <<a href="mailto:mario@emmenlauer.de">mario@emmenlauer.de</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Dear all,<br>
<br>
I've just discovered that option() behaves differently than I anticipated.<br>
After reading the docs and searching with google I'm still confused how to<br>
achieve my desired behaviour.<br>
<br>
What I've just learned is that unspecified options take their cached value<br>
and do *not* go back to their default value, if a cache exists. I assumed<br>
that options take their default when not explicitly specified.<br></blockquote><div><br></div><div>The behavior of option() gained new behavior in CMake 3.13.<div>May be it could help in your particular case: <a href="https://cmake.org/cmake/help/v3.13/policy/CMP0077.html#policy:CMP0077">https://cmake.org/cmake/help/v3.13/policy/CMP0077.html#policy:CMP0077</a></div><div><br></div><div>you'll depend on latest CMake though.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Now my problem: I could not find a way to get the behaviour I'd like. Is it<br>
possible to enforce the default for an option when its not specified by the<br>
user, even if a cache exists?<br></blockquote><div><br></div><div>You mean you did not manage to force the cache value?</div><div>You can:</div><div>set(VAR "default_value" CACHE FORCE)</div><div><br></div><div>or the problem is you cannot know whether if a value has been user-provided?</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I tried to unset() the option from the cache but that does not do what I'd<br>
like.<br>
<br>
All the best,<br>
<br>
Mario Emmenlauer<br>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div></div>