Recently I have learnt a gcc compile option called -finstrument-functions
. What it does is to add a function decorator to each function, by changing the function from
void f(...) {
...
}
into
void f(...) {
__cyg_profile_func_enter(this_func, call_site);
...
__cyg_profile_func_exit(this_func, call_site);
}
What I need to do is to add the definition of __cyg_profile_func_enter
and __cyg_profile_func_exit
.
It is easy to add the definition in a small project with only a few files, but how could I add the function definition to all files in a big cmake project? Is there an option in cmake, or a compile option, to add the definition without updating the configuration of all targets in the cmake project manually?