[CMake] Specifying different warning levels for debug and release
Jack Kelly
endgame.dos at gmail.com
Tue Jul 10 05:18:42 EDT 2007
Paul Richards wrote:
> Hi,
> Is there a way to specify different warning levels for debug and release?
>
> Under Visual Studio 2003 we like to build debug with warning level 4,
> and release at warning level 3.
>
> Can CMake do this?
I don't know if Visual Studio uses CFLAGS for warning level (I assume it
does), but this is how I'd do it for gcc:
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS_DEBUG -g -Wall -Werror)
SET(CMAKE_C_FLAGS_RELEASE -O2 -pipe -fomit-frame-pointer -DNDEBUG)
# And the other build types if necessary
ENDIF(CMAKE_COMPILER_IS_GNUCC)
Similarly, you can test for CMAKE_COMPILER_IS_GNUCXX and set
CMAKE_CXX_FLAGS_*
The CFLAG variable used depends on CMAKE_BUILD_TYPE: None, Debug,
Release, RelWithDebInfo, MinSizeRel, each of which corresponding to an
appropriate CMAKE_LANG_FLAGS_TYPE entry in the cache.
Perhaps testing on IF(MSVC) will be helpful for you. See
http://www.cmake.org/Wiki/CMake_Useful_Variables
-- Jack
More information about the CMake
mailing list