[CMake] How to avoid unneeded dependencies on headers?

Andrew Guryanov andrew-guryanov at usa.net
Tue Sep 18 11:37:50 EDT 2018


Hello,

I use cmake version 3.11.0.
I have the following program (in file "c.c"), where headers a.h and b.h are
empty:

#include "a.h"
#if 0
#include "b.h"
#endif
int main()
{
return 0;
}

and CMakeLists.txt:
add_executable(test c)


I run "cmake ." to configure it and then "make".
Everything builds fine.
I then "touch b.h" and again run "make" -
Make rebuilds it!

I mean, header b.h is excluded, any changes to it may be ignored.
Why there is a dependency on it?
Is this by design?
Is it possible to avoid it?

Thanks




More information about the CMake mailing list