Conditional includes generate unconditional dependencies

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

Conditional includes generate unconditional dependencies

Elliott Slaughter
One of my colleagues recently pointed out to me that CMake generates unconditional dependencies for headers that are included behind an #ifdef even when said #ifdef is disabled. I've managed to confirm this with CMake 3.13.4 using the following reproducer:


Is there a way to get CMake dependency generation to obey the conditional? The workaround we've found so far are undesirable (marking the entire folder as a system path, which isn't appropriate in our use case) or ugly (using implicit depends include transforms).

We understand that the build would be "correct" in any case, as CMake's dependency generation is conservative, but in our case this is causing massive performance issues as the build machine is an embedded device attached to NFS and the dependency tree we're pulling in so large that we're thrashing the file system.


Elliott Slaughter

"Don't worry about what anybody else is going to do. The best way to predict the future is to invent it." - Alan Kay


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: