# How to use relative paths when generating code coverage info

**URL:** https://discourse.cmake.org/t/how-to-use-relative-paths-when-generating-code-coverage-info/8572
**Category:** Usage
**Tags:** os:linux, comp:gcc
**Created:** [July 21, 2023, 1:45pm UTC](https://discourse.cmake.org/t/how-to-use-relative-paths-when-generating-code-coverage-info/8572 "2023-07-21T13:45:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![amlamarra](https://discourse.cmake.org/user_avatar/discourse.cmake.org/amlamarra/32/3636_2.png) [@amlamarra](https://discourse.cmake.org/u/amlamarra)
#### Post date: [July 21, 2023, 1:45pm UTC](https://discourse.cmake.org/t/how-to-use-relative-paths-when-generating-code-coverage-info/8572/1 "2023-07-21T13:45:37Z")

</div>

When I manually compile code to generate coverage info with `g++ --coverage ...`, it will generate gcno files using relative paths. If I wanted them to be absolute paths, I would add `-fprofile-abs-path`. However, when using CMake and adding `--coverage` to `CMAKE_CXX_FLAGS`, it always uses absolute paths. I need them to be relative paths. Is there a way to do this?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [July 24, 2023, 9:49am UTC](https://discourse.cmake.org/t/how-to-use-relative-paths-when-generating-code-coverage-info/8572/2 "2023-07-24T09:49:11Z")

</div>

Using relative paths may be problematic. See the following issue for some background: [https://gitlab.kitware.com/cmake/cmake/-/issues/20001](https://gitlab.kitware.com/cmake/cmake/-/issues/20001)
