[CMake] Nice handling of code coverage option?

Brad Hards bradh at frogmouth.net
Thu Mar 25 07:23:41 EDT 2010


On Thursday 25 March 2010 10:09:44 pm Verweij, Arjen wrote:
> We use gcov and lcov for our C++ code. I think you should take care to make
> sure you have the same version gcov as gcc/g++. 
I'll look to add this. I was worried about how to find out whether the build 
uses gcc or g++ (i.e. how do you know what to compare it to?).

> Also I think you get
> better results if you compile using -O0. Optimization will confuse the
> postprocessing.
How do you prevent using some other option? My approach was just to warn
if the build is not a Debug build, with this:
    if ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
        message( WARNING "Code coverage results with an optimised (non-Debug) 
build may be misleading" )
    endif ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )

Do you have something else?

Brad


More information about the CMake mailing list