<div dir="ltr">See the first item on the following article for guidance on how to combine cache and non-cache values for CMAKE_CXX_FLAGS:<div><br></div><div><a href="http://voices.canonical.com/jussi.pakkanen/2013/03/26/a-list-of-common-cmake-antipatterns/">http://voices.canonical.com/jussi.pakkanen/2013/03/26/a-list-of-common-cmake-antipatterns/</a><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 3, 2017 at 12:19 PM, Andrew Maclean <span dir="ltr"><<a href="mailto:andrew.amaclean@gmail.com" target="_blank">andrew.amaclean@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Craig,</div>   Thanks for this, I had forgotten the distinction between non-cached variables and cached variables<div><br><div>I guess the issue is that whilst it is possible to modify the cached entry, it will never be used since the non-cached variable will always override it whenever cmake is invoked.<br><div><br></div><div>Andrew</div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 3, 2017 at 10:26 AM, Craig Scott <span dir="ltr"><<a href="mailto:craig.scott@crascit.com" target="_blank">craig.scott@crascit.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Your CMakeLists.txt file is modifying the <i>non-cache</i> variable CMAKE_CXX_FLAGS. During CMake processing, a non-cache variable will override a cache variable of the same name, but modifying a non-cache variable won't update the cache. CMake is working as designed with regard to the handling of CMAKE_CXX_FLAGS here, your expectation of the cache being updated to reflect your changes to the non-cache variable is the source of the confusion. Please review the following link which describes this in more detail:<div><br></div><div><a href="https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#variables" target="_blank">https://cmake.org/cmake/help/l<wbr>atest/manual/cmake-language.7.<wbr>html#variables</a><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_7633128477335805844h5">On Fri, Feb 3, 2017 at 10:01 AM, Andrew Maclean <span dir="ltr"><<a href="mailto:andrew.amaclean@gmail.com" target="_blank">andrew.amaclean@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_7633128477335805844h5"><div dir="ltr">Consider the attached CMakeLists.txt script.<div><br><div>When run, CMAKE_CXX_FLAGS is updated correctly, however the line:</div><div>CMAKE_CXX_FLAGS:STRING=/DWIN32 /D_WINDOWS /W3 /GR /EHsc</div><div>in CMakeCache.txt is never updated. <br clear="all"><div><br></div><div>However the build instructions e.g build.ninja reflect the correct command:</div><div> FLAGS = /DWIN32 /D_WINDOWS /W4 /GR /EHsc /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1<br></div><div>Similarly for the Visual Studio Build.</div><div><br></div><div>I see this behaviour in my own code and also in VTK.</div><div><br></div><div>Is there a reason why CMakeCache.txt does not get the update?</div><span class="m_7633128477335805844m_-3004824856675099922HOEnZb"><font color="#888888"><div><br></div><div>Andrew</div><div><br></div><div><br></div>-- <br><div class="m_7633128477335805844m_-3004824856675099922m_5595838732515058528gmail_signature">______________________________<wbr>_____________<br>Andrew J. P. Maclean<br><br>______________________________<wbr>_____________</div>
</font></span></div></div></div>
<br></div></div>--<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/CMak<wbr>e_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/su<wbr>pport.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/co<wbr>nsulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/tr<wbr>aining.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/opensou<wbr>rce/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/cmake</a><span class="m_7633128477335805844HOEnZb"><font color="#888888"><br></font></span></blockquote></div><span class="m_7633128477335805844HOEnZb"><font color="#888888"><br><br clear="all"><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_7633128477335805844m_-3004824856675099922gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</font></span></font></span></div><span class="HOEnZb"><font color="#888888">
</font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_7633128477335805844gmail_signature" data-smartmail="gmail_signature">______________________________<wbr>_____________<br>Andrew J. P. Maclean<br><br>______________________________<wbr>_____________</div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</div>