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

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?

有帮助吗?

解决方案

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)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top