asserson
asserson

Reputation: 21

gcov/lcov: problems generating coverage for header files

lcov does not generate coverage data for header-files included using path relative to project root.

I have the following simplified file structure: ./main/main.cpp:

#include "bar/bar.hpp"
int main()
{
    Bar bar;
}

./bar/bar.hpp:

struct Bar
{
    Bar(){}
};

./Makefile:

cov: app
    ./app
    lcov -c -d . -b . -o cov.info
    genhtml cov.info --output-directory ./html/

GCOV_FLAGS = -g -fprofile-arcs -ftest-coverage

app : main/main.o
    g++ ${GCOV_FLAGS} main/main.o -o app

main/main.o : main/main.cpp
    g++ -I. ${GCOV_FLAGS} -c main/main.cpp -o main/main.o

When I run make cov I get the following warning:

geninfo: WARNING: no data found for /home/casserso/playground/gcov/./bar/bar.hpp

and no coverage data is generated for bar.hpp

If I change #include "bar/bar.hpp" to #include "../bar/bar.hpp" in main.cpp everything is fine.

Can somebody please help me resolve this issue

Thanks Christian

Upvotes: 1

Views: 2503

Answers (1)

asserson
asserson

Reputation: 21

Updating lcov version from 1.7 to 1.9 solved the problem.
Thanks for all input.

Upvotes: 1

Related Questions