2

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?

cbuchart
  • 10,847
  • 9
  • 53
  • 93
quesyKing
  • 148
  • 7

1 Answers1

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.

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