Am Saturday 22 November 2008 15:17:12 schrieb Vladimir Prus: > Michael Jackson wrote: > > On Nov 22, 2008, at 8:01 AM, Vladimir Prus wrote: > >> Bill Hoffman wrote: > >>> Robert Dailey wrote: > >>>> Hi, > >>>> > >>>> I've done some googling on how to set warning levels for visual > >>>> studio > >>>> projects generated with CMake and I can't say I really enjoy the > >>>> proposed solutions I've found. Literally this should be a single > >>>> function call like: > >>>> > >>>> cmake_warning_level( 4 ) > >>>> > >>>> I expected something simple like above, but instead I found > >>>> solutions > >>>> that involved over 10 lines of code and very complex logic. This is > >>>> really starting to discourage me from using CMake. I won't jump > >>>> the gun, > >>>> though, and I'll assume that I just haven't found that magically > >>>> simple > >>>> solution yet. Help is greatly appreciated! > >>> > >>> CMake does not yet have a feature to flag type of mapping layer like > >>> that. It is on the road map for the future. It could be and is done > >>> with macros or functions in projects currently. I am pretty sure the > >>> boost CMake files have macros that do this. Anyone have a macro for > >>> this to post? > >> > >> Boost.Build allows you to write: > >> > >> bjam warnings=all > >> > >> and this will lead to /W4 on msvc (and to suitable options on other > >> compilers) > >> > >> I don't think boost's CMake setup has this specific option, and > >> generally, > >> lacks most of advanced Boost.Build mechanisms necessary to portably > >> specify build properties. > >> > >> - Volodya > > > > Vladimar, > > Could you please enumerate the advanced options that are missing > > from boost's cmake setup so that I can start working on implementing > > those options. (Cross Posting to Boost-CMake as that may become the > > more appropriate place for this ) > > It might be a little bit hard to summarize several years of development, > and a pile of code ;-) > > The key components (relevant to the original question of setting compiler > options more-or-less portably) are: > > 1. Mechanism to map from portable build features to compiler options -- > e.g. setting certain flag when the compiler is gcc and target-os=windows > and link=shared. > > 2. Mechanisms to refine features a specific target is built with depending > on requested features (e.g. on msvc, disable all warnings) > > > What are the equivalents in gcc to /w4, /w3, /w2, /w1? > > Here's the relevant code: > > toolset.flags gcc.compile OPTIONS <warnings>off : -w ; > toolset.flags gcc.compile OPTIONS <warnings>on : -Wall ; > toolset.flags gcc.compile OPTIONS <warnings>all : -Wall -pedantic ;
All warnings on gcc are: -O3 -g -W -Wall -pedantic -std=<somevalue> On msvc you usually want to disable some very useless warnings (like that funny proposal to replace "unsafe" POSIX functions with microsoft-only "safe" functions) and that is not handled by /w? as some other warnings may still be useful. On gcc, when using the -pedantic option, you should also set the standards version that your program complies to or you will get lots of useless warnings/errors. To get some warnings, you need optimisation turned on and also use -g or you will never see them. That may still not be all warnings, depending on OS and on versions of gcc. I don't see how this could be handled by a simply integer. HS _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake