[CMake] Dependency problem

Alexander Neundorf a.neundorf-work at gmx.net
Mon Jun 22 17:52:51 EDT 2009


On Monday 22 June 2009, pjtr hahn wrote:
> 2009/6/22 Tyler Roscoe <tyler at cryptio.net>:
> > Are you sure it doesn't Just Work if you do it the straightforward way?
>
> Yes I am. I tried all combinations.
>
> If I add the phony_name AND the *.cpp as OUTPUT it will compile on
> every run regardless if the .cpp has been touched by the command or
> not.
> If I only add the phony_name the *.cpp needs a second run to compile.
> If I only add the *.cpp my custom command is only run once.
>
> > 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.
>
> This is what I am actually doing in my script that is run by the
> custom command. I leave the *.cpp untouched based on some external
> condition even if the rule is executed at every build.
> This is what I try to achive. Run the custom command at every build,
> check some conditions and based on them update the *.cpp. If the
> update condition is met and the file was touched then recompile.
>
> > But really I think it will just work if you add the relevant
> > OUTPUT/DEPENDS parameters to your custom commands/targets.
>
> No. OUTPUT definitely doesn't work as expected. Adding the *.cpp to
> OUTPUT causes a recompile on every run even if the file was untouched.

Please post an example which shows this issue.
It should really work (and does here).

Alex


More information about the CMake mailing list