# auto increment project versions

**URL:** https://discourse.cmake.org/t/auto-increment-project-versions/3250
**Category:** Code
**Created:** [May 3, 2021, 10:15am UTC](https://discourse.cmake.org/t/auto-increment-project-versions/3250 "2021-05-03T10:15:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hex/32/363_2.png) [@hex](https://discourse.cmake.org/u/hex)
#### Post date: [May 3, 2021, 10:15am UTC](https://discourse.cmake.org/t/auto-increment-project-versions/3250/1 "2021-05-03T10:15:12Z")

</div>

how can project versions be incremented automatically? `project()` must be called directly so i cannot generate and include it later. What i can do is set the project version seperately.

Do i have to set all variants of

CMAKE\_PROJECT\_VERSION  
PROJECT\_VERSION  
MyProj\_VERSION

for major, minor, etc or is there a more direct way to do it?

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [May 3, 2021, 10:25am UTC](https://discourse.cmake.org/t/auto-increment-project-versions/3250/2 "2021-05-03T10:25:57Z")

</div>

You can still do stuff before a call to `project()` if memory serves, it should be possible to, for example, load the version from file to a variable and use that in a call to `project()`.

Someone please correct me if I’m wrong.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [May 3, 2021, 11:58am UTC](https://discourse.cmake.org/t/auto-increment-project-versions/3250/3 "2021-05-03T11:58:39Z")

</div>

You can definitely do this. In fact, Qt6 does exactly this.
