'How to manually postprocess CMake target during installation?

I am working on a library that provides gdb pretty-printers. They could be automatically located by including the .debug_gdb_scripts section in the generated binary. For binaries inside build, I would like this section to point to the pretty-printer inside the source tree. For installed binaries, I would like to either strip this specific section only, or install the pretty-printer as well and change the reference to its installed location.

Is there builtin functionality in CMake or a simple solution to postprocess the installed binary?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source