On 2013-03-13 09:22, Martin Koller wrote:
I'd like to solve the following problem, but have not found a way how to yet:

Our source is rebuilt every night, but only if some sources changed (e.g.
the build tree is not removed, only the source tree is updated from CVS).

What I want is to include the build date/time in a versionInfo.cxx sourcefile
(with __DATE__ and __TIME__ macros) if and only if the executable needs a 
rebuild.
That is, the executable has a commandline option "-version" which should print
the information "build time: xxxxx"

So what I need is something like a rule:
"if the exe needs a rebuild (any dependant source changed except the 
versionInfo.cxx file),
rebuild the versionInfo.o file and link it to the executable"

Any ideas ?

The easiest way would be to wrap your update with a script that checks if anything happened, and if so, writes the current date/time to a file. Then just include this file in your build.

Or you could write a custom command to stick the current VCS revision into a file (or even take the hashes of all source files) and do a copy_if_different on this, then write another custom command that depends on the copied file that updates your versionInfo.cxx. The copy_if_different will prevent the dependency file changing if the source tree has not changed, which will prevent the rule to make a new time/date stamp from running and making versionInfo.cxx modified.

--
Matthew

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to