CTestCoverageCollectGCOV
Added in version 3.2.
This module is intended for use in CTest dashboard scripts and provides a command to generate a tarball containing code coverage reports.
Load this module in a CTest script with:
include(CTestCoverageCollectGCOV)
Commands
This module provides the following command:
-
ctest_coverage_collect_gcov -
Runs
gcovand packages a tar file for CDash:ctest_coverage_collect_gcov( TARBALL <tar-file> [TARBALL_COMPRESSION <compression>] [SOURCE <source-dir>] [BUILD <build-dir>] [GCOV_COMMAND <gcov-command>] [GCOV_OPTIONS <options>...] [GLOB] [DELETE] [QUIET] )
This command runs
gcovon all.gcdafiles found in the binary tree and packages the resulting.gcovfiles into a tar file, along with the following:- data.json file that defines the source and build directories for use by CDash.
-
Labels.json files that indicate any
LABELSthat have been set on the source files. - The uncovered directory containing any uncovered files found by
CTEST_EXTRA_COVERAGE_GLOB.
The resulting tar file can be submitted to CDash for display using the
ctest_submit(CDASH_UPLOAD)command.The arguments are:
-
TARBALL <tar-file> -
Specify the location of the
.tarfile to be created for later upload to CDash. Relative paths will be interpreted with respect to the top-level build directory. -
TARBALL_COMPRESSION <compression> -
Added in version 3.18.
Specify a compression algorithm for the
TARBALLdata file. Using this option reduces the size of the data file before it is submitted to CDash.<compression>should be one of the following:GZIPBZIP2-
LZMAAdded in version 4.3.
-
LZMA2Added in version 4.3.
This is an alias for
XZ. XZZSTDFROM_EXT- An expression that CMake evaluates as
FALSE
The default value is
BZIP2.If
FROM_EXTis specified, the resulting file will be compressed based on the file extension of the<tar-file>(i.e..tar.gzwill useGZIPcompression). File extensions that will produce compressed output include:.tar.gz.tgz.tar.bzip2.tbz.tar.xz.txz-
.tar.lzmaAdded in version 4.3.
-
.tlzmaAdded in version 4.3.
-
.tar.zstAdded in version 4.3.
-
.tzstAdded in version 4.3.
-
SOURCE <source-dir> -
Specify the top-level source directory for the build. Default is the value of
CTEST_SOURCE_DIRECTORY. -
BUILD <build-dir> -
Specify the top-level build directory for the build. Default is the value of
CTEST_BINARY_DIRECTORY. -
GCOV_COMMAND <gcov-command> -
Specify the full path to the
gcovcommand on the machine. Default is the value ofCTEST_COVERAGE_COMMAND. -
GCOV_OPTIONS <options>... -
Specify options to be passed to gcov. The
gcovcommand is run asgcov <options>... -o <gcov-dir> <file>.gcda. If not specified, the default option is just-b -x. -
GLOB -
Added in version 3.6.
Recursively search for
.gcdafiles in<build-dir>rather than determining search locations by readingCMakeFiles/TargetDirectories.txt(file generated by CMake at the generation phase). -
DELETE -
Added in version 3.6.
Delete coverage files after they've been packaged into the
.tar. -
QUIET -
Suppress non-error messages that otherwise would have been printed out by this command.
Added in version 3.3: Added support for the
CTEST_CUSTOM_COVERAGE_EXCLUDEvariable.
Examples
Generating code coverage data packaged as a .tar.gz file in a ctest -S script:
script.cmakeinclude(CTestCoverageCollectGCOV)
ctest_coverage_collect_gcov(
TARBALL "${CTEST_BINARY_DIRECTORY}/gcov.tar.gz"
TARBALL_COMPRESSION "GZIP"
)
© 2000–2026 Kitware, Inc. and Contributors
Licensed under the BSD 3-clause License.
https://cmake.org/cmake/help/latest/module/CTestCoverageCollectGCOV.html