有关使用gcov与CMake / CDash的详细指南? [英] Detailed guide on using gcov with CMake/CDash?

查看:977
本文介绍了有关使用gcov与CMake / CDash的详细指南?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CMake与我的项目,并设置cdash服务器连续/每夜建设。一切都很好,通过设置crontab,我们每小时/每夜构建/测试结果自动上传到我们的cdash服务器。

I'm using CMake with my project and set up a cdash server for continuous/nightly building. Everything works well and by setting up a crontab, we have hourly/nightly build/test results uploaded to our cdash server automatically.

我的下一步是添加测试覆盖报告到构建。我在这里找到文档 http://www.cmake.org/Wiki/CTest:Coverage ,但坦率地说,它是一个

My next step is to add test coverage report to the build. I find the document here http://www.cmake.org/Wiki/CTest:Coverage but frankly it's a bit far from a practical guide.

目前我已经添加了所需的标志(而不是 -fprofile-arcs -ftest-coverage ,我找到 - 覆盖更好),编译过程生成.gcno文件。但是,然后我被卡住了。命令

Currently I've added the required flag (instead of -fprofile-arcs -ftest-coverage, I find --coverage better), the compilation process generates .gcno files. But then I'm stuck. The command

make NightlyCoverage

似乎没有做任何事情。有谁能告诉我下一步做什么?我想要的结果是通过 make NightlyCoverage ,生成覆盖率报告并上传到cdash服务器。

doesn't seem to do anything. Could anybody tell me what is the next to do? The result that I want, is by doing make NightlyCoverage, coverage reports are generated and uploaded to cdash server.

推荐答案

我一直在使用 https://github.com /bilke/cmake-modules/blob/master/CodeCoverage.cmake

按照指南操作:将文件添加到我的 CMAKE_MODULE_PATH 目录,添加

Just followed the guidelines: added the files to my CMAKE_MODULE_PATH directory, added

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
if(CMAKE_COMPILER_IS_GNUCXX)
    include(CodeCoverage)
    setup_target_for_coverage(${PROJECT_NAME}_coverage ${PROJECT_TEST_NAME} coverage)
endif()

在我的 CMakeLists.txt 。我也手动添加 gcov 作为我的目标的依赖:

in my CMakeLists.txt. I also added manually gcov as a dependency for my target:

if(CMAKE_COMPILER_IS_GNUCXX)
    target_link_libraries(${PROJECT_TEST_NAME} gcov)
endif()

这样,我只需输入

make my_project_coverage

,我在构建树的 coverage 目录中获取html报告。

and I get the html report in the coverage directory of my build tree.

这篇关于有关使用gcov与CMake / CDash的详细指南?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆