I am trying to get my project generates a file with relevant compile data (compiler version, lib version, date, git commit, etc). So my question is how do I make this run only at compile time, when it will have access to the needed information?
Asked
Active
Viewed 131 times
2
-
1Mentioning what build system you are using may be useful when asking about how to make a build system do something. I could guess qmake? – Yakk - Adam Nevraumont May 30 '17 at 17:29
-
what you want is a log of the compile process, that, if available, should be a configuration on your compiler... – DIEGO CARRASCAL May 30 '17 at 17:29
1 Answers
3
What about the compilation log? If it doesn't provide enough information, you can create a script that gathers the data and print it to a file.
Compiler version:
- For Visual Studio, you can check this answer.
- If your compiler is gcc use
gcc --version
.
Current git commit can be obtained by any of the methods described here.
Library versions will depend on each particular case: maybe the compilation log have that data for some of them, print the library path (sometimes such directories contain the version number, at least for some libraries), etc.
Current date/time:
- bash:
date +%Y-%m-%d:%H:%M:%S
- Windows' command line, check this answer.
- bash:
Finally, the script can be invoked as the last step in your makefile or as a post-build event in the case of a Visual Studio project.

cbuchart
- 10,847
- 9
- 53
- 93