[CMake] Trigger rebuild when a system header changes

Lassi Niemistö lassi.niemisto at wapice.com
Tue Mar 19 03:12:02 EDT 2019


Hello,

It seems CMake has a special handling for system header dependencies. I.e. if my .c file includes /usr/include/someheader.h, modifying the someheader.h does not cause the .c file to be rebuilt.

How to work around this issue? We have some custom libraries that get installed to system paths and they change relatively often. It is error-prone for the developers to accidentally keep using the library with old header compiled in.

Things I have tried this far:
* add_dependencies(target /path/to/header.h)  --> no luck
* add_library(include_deplib /path/to/header.h) + target_link_libraries(target include_deplib) --> needs additional tweaking to be legal, still does not work
* OBJECT_DEPENDS property pointing to the .h file--> This works but I need to do this for each c. file separately

I wonder if this should be this difficult, I am probably missing something? Can I just somehow enable tracking system headers also as expected-to-change dependencies?

-Lassi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190319/7b2a675f/attachment.html>


More information about the CMake mailing list