# Patch source with instrumentation without altering original code

**URL:** <https://discourse.cmake.org/t/patch-source-with-instrumentation-without-altering-original-code/2338>\
**Category:** Code\
**Created:** [December 10, 2020, 1:28pm UTC](https://discourse.cmake.org/t/patch-source-with-instrumentation-without-altering-original-code/2338 "2020-12-10T13:28:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![StefanSchmelz](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/ccd318/32.png) [@StefanSchmelz](https://discourse.cmake.org/u/StefanSchmelz)\
**Post date:** [December 10, 2020, 1:28pm UTC](https://discourse.cmake.org/t/patch-source-with-instrumentation-without-altering-original-code/2338/1 "2020-12-10T13:28:59Z")

</div>

I want to use libtooling to generate instrumentattion code for debug builds. I will manage to run my generator from cmake, but i don’t really know how i could patch my Instrumentation into the source without altering the normal files.

At least if i can not manage to output complete source files from my generator.

Hope my question hast not been asked too often

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [December 10, 2020, 6:45pm UTC](https://discourse.cmake.org/t/patch-source-with-instrumentation-without-altering-original-code/2338/2 "2020-12-10T18:45:06Z")

</div>

Do you have an example of how this would work without CMake (i.e., what the command line looks like for doing what you want at all)? If not, I think this may be more of an LLVM/Clang question at first, but once it’s known how to do it outside of CMake, translating it into how to make CMake generate that information would go here.
