Cmake adds gcov code coverage test support

Source: Internet
Author: User
Tags gcov

Add gcov to cmakeCodeCoverage test support

(Jinqing's column)

Add the enable_gcov option to root cmakelist.txt:

Option (enable_gcov "enable gcov (debug, Linux builds only)" Off)

If (enable_gcov and not Win32 and not Apple)
Set (cmake_cxx_flags_debug "$ {cmake_cxx_flags_debug}-fprofile-arcs-ftest-coverage ")
Set (cmake_c_flags_debug "$ {cmake_c_flags_debug}-fprofile-arcs-ftest-coverage ")
Set (cmake_exe_linker_flags_debug "$ {cmake_exe_linker_flags_debug}-fprofile-arcs-ftest-coverage-lgcov ")
Endif ()

Use the code above to upload the cmakelists.txt of mysql.

Run cmake as follows:

Cmake src_dir-dcmake_build_type = debug-denable_gcov = 1

After compilation, you can see the graph file *. gcno.

After running, you can see that the data file *. gcda is generated.

Run gcov main. cpp. gcno to generate the main. cpp. gcov test result.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.