[cmake-developers] Source file dependencies

Wouter Klouwen wouter.klouwen at youview.com
Thu Dec 7 13:08:47 EST 2017


Hi all,

In trying to improve our build rules, one of the problems I encountered
is that I effectively have some source files that cannot be compiled
unless certain targets are run.

I noticed that cmSourceFile has the AddDepend() method, which looks to
do the kind of thing that I want to do.
cmFlTKWrapUICommand and cmCPluginAPI are the only users of this, with
there being no way of setting this from a CMakeLists.txt.
The former seems to do exactly the kind of think that I need, which is
to set up some code generation.

It would be nice if I could add items to this list, perhaps through
setting a property on the source files themselves, e.g this rather
contrived short example:

add_custom_command(OUTPUT bar.h COMMAND touch bar.h)
add_custom_target(bar DEPENDS generate_bar bar.h)
set_source_files_properties(foo.cpp PROPERTIES DEPENDS bar)

Is this a bad idea? Would there be a better way?

Thanks,
    W
This transmission contains information that may be confidential and contain personal views which are not necessarily those of YouView TV Ltd. YouView TV Ltd (Co No:7308805) is a limited liability company registered in England and Wales with its registered address at YouView TV Ltd, 3rd Floor, 10 Lower Thames Street, London, EC3R 6YT. For details see our web site at http://www.youview.com


More information about the cmake-developers mailing list