-
Notifications
You must be signed in to change notification settings - Fork 389
Troubleshooting
Some help to frequent problems that may arise.
The tests use the default gcc available on the current platform (as it's a good way to ensure compatibility with common build systems), but you can override it to use another version. Currently, ubuntu-latest seems to support at least gcc-9. If you want to use that, you can change your action accordingly.
- name: configure
run: CXX=g++-9 cmake -Htest -Bbuild -DENABLE_TEST_COVERAGE=1
Be sure to also use the correct version of gcov.
- name: collect code coverage
run: bash <(curl -s https://codecov.io/bash) -x gcov-9 || echo "Codecov did not collect coverage reports"
The library type has to be changed to an interface library and all operations on the library must have INTERFACE
scope.
See here for an example.
Then you might want to create an extra target only for the headers.
add_library(MyLibraryHeaders EXCLUDE_FROM_ALL ${headers})
set_target_properties(MyLibraryHeaders PROPERTIES LINKER_LANGUAGE CXX)
Always pass all dependencies to PackageProject.cmake so CMake will look for them when adding the library. See here for an example.
For template heavy libraries the default settings of codecov might not not work accurately. In that case it can make sense to manually collect the coverage data. Note that the versions of gcc and gcov must be compatible. See here for an example workflow.