在 CMake/CDash 中使用 gcov 的详细指南?

Detailed guide on using gcov with CMake/CDash?(在 CMake/CDash 中使用 gcov 的详细指南?)

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

问题描述

我在我的项目中使用 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,我发现 --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 成功.

I've been using https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake successfully.

只是按照指导方针:将文件添加到我的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.

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

本文标题为:在 CMake/CDash 中使用 gcov 的详细指南?

基础教程推荐