[CMake] Building a Version Header

Michael Hertling mhertling at online.de
Sun Jul 11 09:48:49 EDT 2010


On 07/09/2010 01:23 PM, Johannes Stallkamp wrote:
> Am 09.07.2010 12:56, schrieb Michael Hertling:
>> As the version target is always out of date it will be build each time
>> you (re)build main, but since CONFIGURE_FILE() obviously does not touch
>> the output file as long as it won't change, version.h isn't timestamped,
>> so it doesn't trigger the rebuild of the main target.
> Hey, that's great. I didn't know that CONFIGURE_FILE does not touch
> the output file if the content doesn't change.
> With that knowledge, I can now simplify my scripts which up to now
> checked manually whether the version number changed and only called
> CONFIGURE_FILE if this is the case.
> Where did you find that? Did I miss it in the docs?

No, AFAIK, this feature isn't documented, and I stumbled across it
eventually by accident. Nevertheless, in CMake's sources, one can
see that CONFIGURE_FILE()'s implementation finally uses a method
named "CopyFileIfDifferent()" to write the output file. ;-)
               ^^^^^^^^^^^
Regards,

Michael


More information about the CMake mailing list