How to avoid unneeded dependencies on headers?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

How to avoid unneeded dependencies on headers?

Andrew Guryanov

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

#include "a.h"
#if 0
#include "b.h"
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?



Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: