@@ -50,11 +50,19 @@ jobs:
5050 compiler : gcc
5151
5252 include :
53+ # Add appropriate variables for gcov version required. This will intentionally break
54+ # if you try to use a compiler that does not have gcov set
55+ - compiler : gcc
56+ gcov_executable : gcov
57+ - compiler : llvm
58+ gcov_executable : " llvm-cov gcov"
59+
5360 # This exists solely to make sure a non-multiconfig build works
5461 - os : ubuntu-20.04
5562 compiler : gcc
5663 generator : " Unix Makefiles"
5764 build_type : Debug
65+ gcov_executable : gcov
5866 developer_mode : On
5967
6068 - os : windows-2022
@@ -119,9 +127,11 @@ jobs:
119127 gcovr : true
120128 opencppcoverage : true
121129
130+ # make sure coverage is only enabled for Debug builds, since it sets -O0 to make sure coverage
131+ # has meaningful results
122132 - name : Configure CMake
123133 run : |
124- cmake -S . -B ./build -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -DENABLE_DEVELOPER_MODE:BOOL=${{matrix.developer_mode}}
134+ cmake -S . -B ./build -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -DENABLE_DEVELOPER_MODE:BOOL=${{matrix.developer_mode}} -DOPT_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }}
125135
126136 - name : Build
127137 # Execute the build. You can specify a specific target with "--target <NAME>"
@@ -135,13 +145,13 @@ jobs:
135145 # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
136146 run : |
137147 ctest -C ${{matrix.build_type}}
138- gcovr -j ${{env.nproc}} --delete --root ../ --print-summary --xml-pretty --xml coverage.xml .
148+ gcovr -j ${{env.nproc}} --delete --root ../ --print-summary --xml-pretty --xml coverage.xml . --gcov-executable '${{ matrix.gcov_executable }}'
139149
140150 - name : Windows - Test and coverage
141151 if : runner.os == 'Windows'
142152 working-directory : ./build
143153 run : |
144- OpenCppCoverage.exe --sources cpp_starter_project -- export_type cobertura:coverage.xml --cover_children -- ctest -C ${{matrix.build_type}}
154+ OpenCppCoverage.exe --export_type cobertura:coverage.xml --cover_children -- ctest -C ${{matrix.build_type}}
145155
146156 - name : Publish to codecov
147157 uses : codecov/codecov-action@v2
0 commit comments