project version from file (semver)

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.

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.).