[CMake] Changing /W3 to /W4 does not update CMakeCache.txt

Andrew Maclean andrew.amaclean at gmail.com
Thu Feb 2 20:19:35 EST 2017


Craig,
   Thanks for this, I had forgotten the distinction between non-cached
variables and cached variables

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.

Andrew

On Fri, Feb 3, 2017 at 10:26 AM, Craig Scott <craig.scott at crascit.com>
wrote:

> Your CMakeLists.txt file is modifying the *non-cache* 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:
>
> https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#variables
>
>
> On Fri, Feb 3, 2017 at 10:01 AM, Andrew Maclean <andrew.amaclean at gmail.com
> > wrote:
>
>> Consider the attached CMakeLists.txt script.
>>
>> When run, CMAKE_CXX_FLAGS is updated correctly, however the line:
>> CMAKE_CXX_FLAGS:STRING=/DWIN32 /D_WINDOWS /W3 /GR /EHsc
>> in CMakeCache.txt is never updated.
>>
>> However the build instructions e.g build.ninja reflect the correct
>> command:
>>  FLAGS = /DWIN32 /D_WINDOWS /W4 /GR /EHsc /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
>> Similarly for the Visual Studio Build.
>>
>> I see this behaviour in my own code and also in VTK.
>>
>> Is there a reason why CMakeCache.txt does not get the update?
>>
>> Andrew
>>
>>
>> --
>> ___________________________________________
>> Andrew J. P. Maclean
>>
>> ___________________________________________
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
>>
>
>
>
> --
> Craig Scott
> Melbourne, Australia
> https://crascit.com
>



-- 
___________________________________________
Andrew J. P. Maclean

___________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170203/bd86db6b/attachment-0001.html>


More information about the CMake mailing list