...
Copy
<CPPTEST_INSTALL_DIR>/integration/cmake/cpptest-coverage.cmake
to your CMake project.Review the coverage configuration details in the
cpptest-coverage.cmake
file and update the options if needed. At a minimum, you must ensure that the compiler configuration specified with theCPPTEST_COMPILER_ID
option matches your compiler. See Customizing the Coverage Extension for CMake for available options.Include the
cpptest-coverage.cmake
extension to your main CMakeLists.txt build file. The extension must precede all build target definitions to ensure that the compiler/linker command lines are automatically modified.Activate the extension with the
CPPTEST_COVERAGE
andCOVERAGE and CPPTEST_HOME
options options when configuring and building your CMake project:Code Block language text > cmake -DCPPTEST_COVERAGE=ON -DCPPTEST_HOME=<CPPTEST_INSTALL_DIR> ..
By default, C/C++test's coverage data files will be created in
<CMAKE_BINARY_DIR>/cpptest-coverage/<CMAKE_PROJECT_NAME>/.cpptest
.Run your application or execute your functional or unit tests.
By default, the C/C++test coverage log file (.clog) will be created in<CMAKE_BINARY_DIR>/cpptest-coverage/<CMAKE_PROJECT_NAME>/<CMAKE_PROJECT_NAME>.clog
.Run Make with the
cpptest_coverage_report
helper target to generate the coverage report:Code Block language text > make cpptest_coverage_report
The coverage report will be generated in the following location:
<CMAKE_BINARY_DIR>/cpptest-coverage/<CMAKE_PROJECT_NAME>/reports
.We recommend generating the coverage report using the Make target. Alternatively, you can use
cpptestcli
with the Coverage test configuration and the .clog file as an input:Code Block language text > cd <CMAKE_BINARY_DIR>/cpptest-coverage/<CMAKE_PROJECT_NAME> > cpptestcli -config "builtin://Coverage" -input <CMAKE_PROJECT_NAME>.clog
...