Skip to content
Snippets Groups Projects
Makefile.coverage.in 2.18 KiB
#######################################################################################################################
#
# Additional make target for generating a code coverage report.
#
# ATTENTION: This file has bee deprecated in project-template and will no longer be maintained.
# DO NOT MODIFY THIS FILE IN THE PROJECT TEMPLATE!
# Use make_coverage.sh.in instead!
#
#######################################################################################################################

#######################################################################################################################
#
# IMPORTANT NOTE:
#
# DO NOT MODIFY THIS FILE inside a project. Instead update the project-template repository and pull the change from
# there. Make sure to keep the file generic, since it will be used by other projects, too.
#
# If you have modified this file inside a project despite this warning, make sure to cherry-pick all your changes
# into the project-template repository immediately.
#
#######################################################################################################################

coverage:
	echo ATTENTION: Using Makefile.coverage.in in your CMake project is deprecated. Please change to make_coverage.sh.in
	rm -f `find . -name "*\.gcda"`
	make test
	lcov --capture --directory . --output-file coverage_all.info
	#lcov capture also includes external stuff like glibc, boost etc.
	#only extract the reports for this project
	lcov --extract coverage_all.info "@CMAKE_SOURCE_DIR@*" -o coverage_incl_build.info
	#Some projects install the library and its headers for testing in the build directory
	#and compile tests and examples against it. This leads to double
	#counting and untested lines in the coverage report. That's why we
	#exclude the build directory from the coverage report (needed if the
	#build directory is in the source tree).
	#Attention: If you make an 'in sorce build' the coverage report will
	#be empty!
	lcov --remove coverage_incl_build.info "@PROJECT_BINARY_DIR@/*" -o coverage.info
	genhtml coverage.info --output-directory coverage_html
	echo ATTENTION: Using Makefile.coverage.in in your CMake project is deprecated. Please change to make_coverage.sh.in