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
___________________________________________
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)
#include <cstdlib>
int main()
{
return EXIT_SUCCESS;
}
--
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