CMake: is it possible to rebuild target when header file part of input list changes that isn't relevant for the objects being output?

StackOverflow https://stackoverflow.com/questions/21851032

Question

I'm working on a library where a header is provided for user convenience. When this header is changed the post-build step to copy the header files is not run, as the build itself is not run, which is because the target per se did not change. Is it possible to make it rebuild the target anyway, when any of the headers in the explicit dependency list changes? Or at least, to trigger the post-build steps somehow?

Was it helpful?

Solution

A general solution would be to add a source file to the library which will do nothing but #include the convenience header file.

To solve this within CMake, you can specify the convenience header file as an additional object dependency for one of the library's sources:

set_property(SOURCE some/library_source.cpp APPEND PROPERTY OBJECT_DEPENDS /full/path/to/convenience/header.h)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top