Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop/trick cmake into not rebuilding if a header file was changed then reverted?

If I accidentally change a header file, save it, and then change it back and re-save, how do I stop cmake from detecting the change and rebuilding all its dependencies. Usually I don't even know it got modified until after I re-run make and it starts a rebuild process.

I've tried some naive manual timestamp changes, but had no luck.

To be clear, I'm looking for a hack or someone who can explain the rules cmake uses. The environment is linux/os x using command line gcc/clang.

like image 884
xaxxon Avatar asked Mar 10 '23 04:03

xaxxon


1 Answers

cmake is a makefile generator (amongst other things it can generate). That's why you build with make.

The behavior you see is indeed standard make behavior. This is a generalized build tool; it rebuilds any "target" by applying the "recipe" for that target whenever the target is outdated. These targets and recipes have been written by cmake.

You can ask make which targets it would rebuild (make --dry-run) and update the timestamp of the header to predate all targets (touch -r oldest_target header.h). Alternatively, to avoid determining which target is oldest, alternate make --dry-run and touch -r using the first target until make --dry-run returns no more targets.

like image 129
MSalters Avatar answered Mar 19 '23 22:03

MSalters