MantisBT - CMake
View Issue Details
0004071CMakeCMakepublic2006-11-23 11:322014-06-02 08:37
Tanguy Krotoff 
Nils Gladitz 
lowfeaturealways
closedfixed 
 
CMake 2.8.11 
0004071: Add a time() function to CMake
Sometimes it can be useful to get the build date/time of a program/lib

I like this
2006-11-23 17:24:00
because it can be very easily be converted to an integer. An integer is interesting because then you can compare build date/time and then have an update system
No tags attached.
zip cmTimeCommand.zip (2,003) 2013-04-15 10:26
https://public.kitware.com/Bug/file/4737/cmTimeCommand.zip
Issue History
2013-04-15 10:26Mark StijnmanFile Added: cmTimeCommand.zip
2013-04-15 10:45Mark StijnmanNote Added: 0032838
2013-06-04 10:16Mark StijnmanNote Added: 0033234
2013-11-02 09:09Stephen KellyNote Added: 0034314
2013-11-02 09:09Stephen KellyStatusassigned => resolved
2013-11-02 09:09Stephen KellyFixed in Version => CMake 2.8.11
2013-11-02 09:09Stephen KellyResolutionopen => fixed
2013-11-02 09:09Stephen KellyAssigned ToBill Hoffman => Nils Gladitz
2014-06-02 08:37Robert MaynardNote Added: 0035997
2014-06-02 08:37Robert MaynardStatusresolved => closed

Notes
(0032838)
Mark Stijnman   
2013-04-15 10:45   
I would like this too, for generating header files with build date strings, version numbers based on release dates, etc, so I figured I'd just implement it. The result is in cmTimeCommand.zip, which I've just uploaded.

This 'time' command takes a variable name, and optionally a format specifier (as defined in http://www.cplusplus.com/reference/ctime/strftime/ [^]). The default is "%Y-%m-%d %H:%M:%S", which happens to be the format the OP requested. Examples:

time(my_iso_date) // 2013-04-15 16:36:05
time(version_number "%Y.%m") // 2013.04
time(build_date "%B %d, %Y") // April 15, 2013
time(my_time "%H:%M") // 16:35

Note that I have tested this by hand, but I'm not sure how you would add a test for this feature to the regression test set, as it will produce different output every time.
(0033234)
Mark Stijnman   
2013-06-04 10:16   
It seems this ticket can be closed with the new STRING(TIMESTAMP ...) feature in 2.8.11.
(0034314)
Stephen Kelly   
2013-11-02 09:09   
Done in 711e2b3b5c674d4f754b5b214d511be6ce7e8f4d
(0035997)
Robert Maynard   
2014-06-02 08:37   
Closing resolved issues that have not been updated in more than 4 months.