[CMake] Generated source files and dependencies(+) (Wojciech Migda)

Alexander Neundorf a.neundorf-work at gmx.net
Wed Sep 9 13:15:57 EDT 2009


On Tuesday 08 September 2009, Wojciech Migda wrote:
> > Why not include it in the foo target, instead of making a new
>
> a_h_gen target and doing extra dependencies manually?
>
> Firstly, we have hundred of source files which may indirectly depend
> generated source files, so we want such information to be covered by
> cmake dependency scanner itself - the problem is that there is no link
> between the library target and the header target.
>
> By no means we want to specify such dependencies manually - that would
> be a nightmare.

If you mean by specifying manually adding the generated header files manually 
to the targets, this can be made much easier with the support of some macro:

macro(generate_stuff srcs )
   ...
   add_custom_command(OUTPUT foo.h ...)
   ...
   set( ${srcs} ${${srcs}} foo.h)
endmacro()


set(mySrcs main.cpp bar.cpp)
generate_stuff(mySrcs template1.xml template2.xml)

add_executable(hello ${mySrcs} )

We are using that a lot e.g. in KDE4.

Alex


More information about the CMake mailing list