Hi, just use ADD_DEFINITION, e.g.
# Disable warnings about deprecated functions (Visual C++ 2005) if(MSVC_VERSION GREATER 1399) ADD_DEFINITIONS("/D_CRT_SECURE_NO_DEPRECATE") endif(MSVC_VERSION GREATER 1399) You could just use "if(WIN32)" but than for all compilers on Windows this option would be set. if(MSVC) should work for all Visual C++ compilers. HTH, Werner On Thu, 2008-06-05 at 16:35 +0200, Martin Apel wrote: > Hi all, > > I am trying to set the CMAKE_CXX_FLAGS or CMAKE_CXX_FLAGS_INIT variable, > such that it contains flags to turn off specific warnings for the Visual > Studio compiler. I definitely want to set these additional flags from > within a CMakeFile, specifying them on the command line or interactively > is not an option. > I have included a Windows-specific file by using > INCLUDE (${CMAKE_SYSTEM_NAME}.cmake) > > The file Windows.cmake contains the line > SET (ENV{CXXFLAGS} "/wd4251") > > However this only works after the PROJECT line within the CMakeFile, > because before it CMAKE_SYSTEM_NAME seems to be unset. On the other > hand, when writing the include statement after the project command, the > CMAKE_CXX_FLAGS seem already to be set. If possible I would like to > specify those flags as initial values, avoiding to use the force option > of the set command. > > What is the recommended way to add platform-specific compiler flags from > within CMakeFiles? > > Any help would be appreciated. > > Martin > > _______________________________________________ > CMake mailing list > CMake@cmake.org > http://www.cmake.org/mailman/listinfo/cmake _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake