[CMake] Embedding up-to-date version info in built library

Kolja Waschk cmuser09 at ixo.de
Tue Dec 15 04:17:04 EST 2009


Hi,

>  add_custom_target(update_version COMMAND echo updating)
>  add_library(mylib version.c)
>  add_dependencies(mylib update_version)

We had exactly this configuration for months and the lib was rebuilt
always... but now that you affirm that it /should/ work better, I
had a deeper look again. The actual cause for the rebuild is the
compile time embedded in version.c. The updater script doesn't check
dependencies. It just computes a new version.c and that new version.c
will always be different from the previous one because the time 
changes. Unless we decide to omit that time info, we need to make
updates of version.c dependent on whether the library should be rebuild
for other reasons. So, we really need to reconsider whether the time info in
that file makes much sense...

Thanks for your help!
Kolja



More information about the CMake mailing list