[CMake] Dependency problem

Tyler Roscoe tyler at cryptio.net
Mon Jun 22 11:47:26 EDT 2009


On Mon, Jun 22, 2009 at 10:53:05AM +0200, pjtr hahn wrote:
> I did not add __my_outfile.cpp to OUTPUT because I don't want it to
> get recompiled at every build but just if it has been really
> regenerated.
> Therefor I made the custom command PHONY and made the PHONY target a
> dependency of __my_outfile.cpp through the OBJECT_DEPENDS property.
> This way the command is run at every build, but since the command
> itself may or may not change __my_outfile.cpp I don't added
> __my_outfile.cpp as OUTPUT.
> For __my_outfile.cpp I would like to have the standard behaviour of
> only recompile it if it was really touched.

Are you sure it doesn't Just Work if you do it the straightforward way?

If it really doesn't, you could try generating your .cpp to somewhere
out of the way and then do cmake -E copy_if_different to get it to the
right place. This way, even if your rule updates your .cpp every time,
it will be only be copied to the place where the compiler looks for it
if it has changed.

But really I think it will just work if you add the relevant
OUTPUT/DEPENDS parameters to your custom commands/targets.

tyler


More information about the CMake mailing list