[CMake] CTest w/ Coverage

Daniel Stonier d.stonier at gmail.com
Sun Apr 12 22:42:27 EDT 2009


Actually, I just discovered an interesting thing.

Cmake generally builds things in two steps, first compile the objects,
then link. Gcc can do it this way, or do it with a one shot command. I
just tried replicating what cmake does manually with gcc on the
command line and nope, no .gcno (gcov) file is generated.

However, if I do it on the command line with the oneshot command, as
in the gcov tutorial, the .gcno file is generated and everything is
fine.

i.e.

TWO-STEP : fails to build hello.gcno

g++ -g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter
-Wunused-function -Wunused -Wno-system-headers -Wno-deprecated
-Woverloaded-virtual -Wwrite-strings -fprofile-arcs -ftest-coverage -o
hello.cpp.o -c hello.cpp
g++ -fprofile-arcs -ftest-coverage hello.cpp.o -o hello

ONE-STEP : builds hello.gcno

g++ -g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter
-Wunused-function -Wunused -Wno-system-headers -Wno-deprecated
-Woverloaded-virtual -Wwrite-strings -fprofile-arcs -ftest-coverage
-fprofile-arcs -ftest-coverage hello.cpp -o hello

At the moment, I can't figure out why...sorry.

2009/4/13 Ian Monroe <ian.monroe at gmail.com>:
> On Sun, Apr 12, 2009 at 8:51 PM, Daniel Stonier <d.stonier at gmail.com> wrote:
>> I'm having a few troubles understanding how to get CTest setup. The
>> wiki is a bit piecemeal and just need a pointer in the right
>> direction.
>>
>> Currently, the ctest results are passing for a simple hello world
>> project, but I can't get coverage working.
>
> I'm in pretty much the exact same position. I'm pretty sure I need to
> write a CTest script to do coverage testing, but the docs mostly seem
> to be innuendo on this subject, so I don't know where to start.
>
> Ian
>


More information about the CMake mailing list