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

Andrew Maclean andrew.amaclean at gmail.com
Thu Feb 2 18:01:46 EST 2017


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

___________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170203/d7067a0a/attachment.html>
-------------- next part --------------
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)

#-----------------------------------------------------------------------------
project ( FIIK )

#-----------------------------------------------------------------------------
# Directory where the CMakeFiles are
set ( CMAKE_FILE_DIR
  ${PROJECT_SOURCE_DIR}/CMake
)

#-----------------------------------------------------------------------------
# Set the compiler warning level and other compiler settings.
#include(${CMAKE_FILE_DIR}/DetermineCompilerFlags.cmake)

message("Old CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
IF(MSVC)
# Use the highest warning level for visual c++ compiler.
  SET(CMAKE_CXX_WARNING_LEVEL 4)
  IF(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
    STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
  ELSE(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
  ENDIF(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
ENDIF(MSVC)
message("New CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")

add_executable(${PROJECT_NAME} main.cxx)
-------------- next part --------------
#include <cstdlib>
int main()
{
    return EXIT_SUCCESS;
}


More information about the CMake mailing list