# Compiler options for code coverage

**URL:** <https://discourse.cmake.org/t/compiler-options-for-code-coverage/13175>\
**Category:** Code\
**Created:** [December 11, 2024, 12:46am UTC](https://discourse.cmake.org/t/compiler-options-for-code-coverage/13175 "2024-12-11T00:46:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bidski](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bidski/32/5189_2.png) [@Bidski](https://discourse.cmake.org/u/Bidski)\
**Post date:** [December 11, 2024, 12:46am UTC](https://discourse.cmake.org/t/compiler-options-for-code-coverage/13175/1 "2024-12-11T00:46:31Z")

</div>

My GCC compiler version (actually the QNX q++ compiler) requires me to specify the following command line arguments to generate code coverage metrics

```auto
-ftest-coverage -fprofile-arcs -nopipe -Wc,-auxbase-strip,$@

```

The first couple of options are obviously simple to add, but the last option poses more issues

```auto
-Wc,-auxbase-strip,$@

```

Here, $@ is the makefile variable for the name of the target being generated which, in this case, needs to be the name of the current object file being generated.

Is there a way achieve this argument in CMake?

---

<div class="post-metadata">

**Author:** ![Bidski](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bidski/32/5189_2.png) [@Bidski](https://discourse.cmake.org/u/Bidski)\
**Post date:** [February 7, 2025, 5:59am UTC](https://discourse.cmake.org/t/compiler-options-for-code-coverage/13175/2 "2025-02-07T05:59:05Z")

</div>

For anyone that is interested, I ended up solving this by making a simple python script that would apply the appropriate transformation to the compiler command line and using this script as the `CXX_COMPILER_LAUNCHER`.
