# Update PROJECT VERSION during build generation time

**URL:** https://discourse.cmake.org/t/update-project-version-during-build-generation-time/6462
**Category:** Usage
**Created:** [September 11, 2022, 4:26pm UTC](https://discourse.cmake.org/t/update-project-version-during-build-generation-time/6462 "2022-09-11T16:26:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![hinell](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hinell/32/2657_2.png) [@hinell](https://discourse.cmake.org/u/hinell)
#### Post date: [September 11, 2022, 4:26pm UTC](https://discourse.cmake.org/t/update-project-version-during-build-generation-time/6462/1 "2022-09-11T16:26:13Z")

</div>

I’m using [`write_basic_package_version_file`](https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html) to generate a version file for a package. Further, I’m using project version to specify a path (`/lib/myProject-${PROJECT_VERSION_MAJOR}`) to a package folder where I’m going to install the said version file.

Suppose I get my version from a git repo. If I create a new git tag and build a project the script has to reflect changes.

I need to update PROJECT\_VERSION cache by `CMakeLists.txt` script obtaining a git repository tag during BUILD TIME, not a configure time. This ideally should help me to avoid running configuration every time I need to update version (I already use `--presets` but still, it’s quite hard).

Any ideas?
