[CMake] Dependency problem

pjtr hahn pjtr.hahn at googlemail.com
Mon Jun 22 04:53:05 EDT 2009


2009/6/19 Tyler Roscoe <tyler at cryptio.net>:
> On Fri, Jun 19, 2009 at 06:10:16PM +0200, pjtr hahn wrote:
>> # generate source file
>> add_custom_command( OUTPUT __phony_target_name
>>      COMMAND some_command_to_generate
>>      ARGS -o __my_outfile.cpp
>>      ....
>> )
>
> Why don't you just do OUTPUT __my_outfile.cpp? That's what OUTPUT is for
> -- to tell CMake which custom_command generates the file you need.

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.

> What is ${__phony_target}? Is it just __phony_target_name?
Yes. Sorry for the typo.

> What is that OBJECT_DEPENDS line trying to accomplish?
It's purpose is to make __my_outfile.cpp depend on __phony_target_name
without forcing it to get recompiled althought it didn't changed.

pjtr


More information about the CMake mailing list