Detailed guide on using gcov with CMake/CDash?

前端 未结 4 2040
后悔当初
后悔当初 2020-12-02 07:50

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/t

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 08:25

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

    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()
    

    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()
    

    With this, I just type

    make my_project_coverage
    

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

提交回复
热议问题