Issue
I just learned how I can use
project(ProjectName VERSION 1.0)
and the configure_file to play with the version and embed it into the binary.
On project documentation I see it also accept a description string.
project(ProjectName VERSION 1.0 description_string)
So I want to use the current datetime at the time cmake is running as the description string.
Wondering if I can use datetime, not commit datetime but current datetime at the time cmake is running?
Solution
You can use string(TIMESTAMP ...)
like this:
string(TIMESTAMP RUN_TIME)
project(ProjectName VERSION 1.0 DESCRIPTION "${RUN_TIME}")
Note, however, that this will be populated only when CMake is actually run on this script. So, for example, you generated your project for, say, Visual Studio and work a few days on it there. If you didn't change the CMake file, remove CMake cache or run cmake on the script any other way your date will be stale.
Answered By - ixSci Answer Checked By - Marilyn (WPSolving Volunteer)