[CMake] Deep dependency checking for custom commands?
Brad King
brad.king at kitware.com
Fri Aug 19 09:51:14 EDT 2005
Chris Green wrote:
> If I have a custom command and I declare a header file as a dependency,
> is there any easy way to tap into CMake's deep dependency checking? ie
> if a header included by that explicitly declared dependency changes, can
> I arrange to have the target regenerated?
Unfortunately there is no easy way to do this now. Having customized
dependency scanning would be very helpful. Something like
ADD_CUSTOM_COMMAND(
OUTPUT myout.txt
COMMAND do_something
DEPENDS_SCANNER my_custom_depends_scanner myinput.txt
)
and then the CMake scanner for C could be exposed so that it could be
used as a DEPENDS_SCANNER.
Please submit a feature request here:
http://www.cmake.org/Bug
...but it looks like a non-trivial feature so it may not get done for a
while.
Meanwhile you might be able to hack something similar to what is done in
ITK for custom dependencies. See the source here:
http://www.itk.org/cgi-bin/viewcvs.cgi/Wrapping/CSwig/CMakeLists.txt?rev=1.55&root=Insight&view=auto
Basically the custom command runs the first time because the output is
not present. The custom command generates its output AND a list of
dependencies. The list is dumped via copy-if-different to a file that
is read by CMake. This causes CMake to re-run and include the list of
dependencies in the DEPENDS argument of the custom command. It is an
ultra-hack that seems to work most of the time. If you code something
similar it will probably get you by until a real feature can be implemented.
-Brad
More information about the CMake
mailing list