[CMake] Running target only if one of the dependencies changed

A A sse3ml at googlemail.com
Fri Sep 3 09:59:49 EDT 2010


Hi,

I have a custom target that runs some unit tests during compile time.
This target is executed on each build, which is of course suboptimal,
because if the unit test suite and all of the dependent libraries are
the same, it's no use to run it. The tricky part is that the unit test
suite links dynamically against some other libraries. Originally I
used ADD_CUSTOM_COMMAND, but the problem is that the unit test target
does not get build if I only change a source file of one of the
libraries. Right now, I have a custom target which is called every
time, and I could hack that to check if the source dependency has
changed (i.e. if the timestamp is more recent than the unit test
suite), but I wonder if there is a nicer way for this. Basically
something as ADD_CUSTOM_COMMAND(TARGET ... DEPENDS ...)

Cheers,
  -j


More information about the CMake mailing list