C'est très dépendant de ton projet et de comment il est buildé. Il n'y a pas grand chose de standard en C++ à ma connaissance.
Dans mon projet en cours, j'ai un fichier version.txt dans lequel la version est inscrite. Mon CMakeLists.txt charge ce fichier pour définir la version du projet CMake :
1 2
| file(STRINGS version VERSION_FROM_FILE)
project(MonProjet VERSION ${VERSION_FROM_FILE}) |
Plus tard dans le build (toujours avec CMake), je génère un fichier SoftwareVersion.hpp avec des informations sur mon soft (cmake version, cmake build type, git hash, git tag, git branch, build machin, build user) :
configure_file(${CMAKE_CURRENT_LIST_DIR}/SoftwareVersion.template SoftwareVersion.hpp)
Partager