問題描述
我在我的項目中使用 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 的詳細指南?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!