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

Wojciech Migda wojtek.golf at interia.pl
Wed Sep 9 13:46:34 EDT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Alexander Neundorf pisze:
> 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.

But this implies that we know beforehand that certain library has
dependency on the generated header or not and that we will construct
the CMakeLists.txt with that in mind. This makes the whole thing not
much different than doing dependency scan of headers outside cmake and
embedding the results by hand. If during the course of development the
dependency of a certain target on a.h will change the contents of the
CMakeLists.txt would have to be changed as well - I don't take this as
an elegant solution, to mention maintenance efforts only.

Isn't there any way to enable cmake to scan this dependency
automatically ?

I even considered using OUTPUT_REQUIRED_FILES to obtain information
whether certain files would have dependency on the generated header to
conditionally enable dependency on it. But this would be yet another
workaround to achieve something I'd expect from this kind of tool as
cmake is to be done transparently. Frankly, I'm a bit surprised that
cmake hasn't got such feature yet. Or I'm just wrong ?

Thanks in advance,

- -Wojciech
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKp+n60iFl+nAyImcRAtGbAJsFNnvRbljipG9VGL88jyrhAoLFpwCePV18
436+WsTsX8daghTVTGtQhjc=
=WLqz
-----END PGP SIGNATURE-----


----------------------------------------------------------------------
Praca za granic±? Zobacz oferty!
http://link.interia.pl/f2331



More information about the CMake mailing list