[cmake-developers] Enabling more compiler warnings

Brad King brad.king at kitware.com
Tue Nov 6 09:13:01 EST 2012


On 11/06/2012 08:55 AM, Stephen Kelly wrote:
> If CMake enabled more warnings by default, developers would notice them 
> locally too before even submitting to the dashboard.

s/would/might/ but it could still be useful.  I'd prefer extra warnings
only in a condition like

 if(NOT CMake_VERSION_IS_RELEASE)
   ...
 endif()

> I would prefer to also add -Wundef, but kwsys is not clean with that flag 
> and creates many warnings, so it would have to be fixed there first.

I'm still catching up getting not-so-portable KWSys changes contributed
for another project into CMake.  After that is done then we can look at it.

> I'm fairly sure it would work with GCC 4.2 or later (and I guess clang as 
> well), which would probably cover many cmake developers. The GCC version 
> check only becomes a lot easier with a recent version of CMake

Just use

 if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND
    NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2)

When built with a CMake that does not define the version variable
one simply won't get the extra warnings.  Not a big deal.

-Brad



More information about the cmake-developers mailing list