# project version from file (semver)

**URL:** <https://discourse.cmake.org/t/project-version-from-file-semver/9478>\
**Category:** Code\
**Created:** [November 21, 2023, 12:59pm UTC](https://discourse.cmake.org/t/project-version-from-file-semver/9478 "2023-11-21T12:59:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![malaterre](https://discourse.cmake.org/user_avatar/discourse.cmake.org/malaterre/32/1971_2.png) [@malaterre](https://discourse.cmake.org/u/malaterre)\
**Post date:** [November 21, 2023, 12:59pm UTC](https://discourse.cmake.org/t/project-version-from-file-semver/9478/1 "2023-11-21T12:59:08Z")

</div>

Hi folks,

I am trying to integrate gitlab-ci and cmake more tightly. I would like to be able to easily extract the project version (semver based) easily.

I think the modern approach today is store the version in a separate JSON file, so that it can be easily parsed from both cmake (string+JSON) and JSON CLI (gitlab-ci script using `jq`).

Is anyone else using this approach ? I’d appreciate existing solution if possible, thanks ! In case this is important I am have a toplevel `vcpkg.json` file.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [November 21, 2023, 1:25pm UTC](https://discourse.cmake.org/t/project-version-from-file-semver/9478/2 "2023-11-21T13:25:10Z")

</div>

You can also generate the file during CMake time and have CMake be the sole source of version information for the build (it can get it from whatever is most convenient to store; `project()`, file reading, etc.).
