{"id":20475311,"url":"https://github.com/emanuelemessina/cmake-git-versioning","last_synced_at":"2025-07-24T06:32:30.709Z","repository":{"id":185105873,"uuid":"529945739","full_name":"emanuelemessina/cmake-git-versioning","owner":"emanuelemessina","description":"A CMake module to auto update the project version numbers from Git tags.","archived":false,"fork":false,"pushed_at":"2022-08-28T19:48:51.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T14:30:50.958Z","etag":null,"topics":["cmake","git","version-control","versioning"],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emanuelemessina.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-08-28T18:27:41.000Z","updated_at":"2024-05-13T17:00:12.000Z","dependencies_parsed_at":"2023-07-31T18:42:32.859Z","dependency_job_id":"aa502027-6878-47e4-a803-40d538d628ba","html_url":"https://github.com/emanuelemessina/cmake-git-versioning","commit_stats":null,"previous_names":["emanuelemessina/cmake-git-versioning"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/emanuelemessina/cmake-git-versioning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emanuelemessina%2Fcmake-git-versioning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emanuelemessina%2Fcmake-git-versioning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emanuelemessina%2Fcmake-git-versioning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emanuelemessina%2Fcmake-git-versioning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emanuelemessina","download_url":"https://codeload.github.com/emanuelemessina/cmake-git-versioning/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emanuelemessina%2Fcmake-git-versioning/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266802640,"owners_count":23986384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmake","git","version-control","versioning"],"created_at":"2024-11-15T15:15:40.397Z","updated_at":"2025-07-24T06:32:30.644Z","avatar_url":"https://github.com/emanuelemessina.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cmake-git-versioning\nA CMake module to auto update the project version numbers from Git tags.\n\n\u003cbr\u003e\n\n## Usage\n\n\u003cbr\u003e\n\n1. Check that git exists, eg: \n    ```cmake \n        find_package(Git)\n        if(GIT_FOUND)\n            message(\"Git found: ${GIT_EXECUTABLE}\")\n        else()\n            message(FATAL_ERROR \"Git not found!\")\n        endif()\n    ```\n\n2. Include the module:\n    ```cmake\n    include(\"path/to/cmake-git-versioning.cmake\")\n    ```\n\n3. You now have access to the [Output Variables](#output-variables).\n\n\u003cbr\u003e\n\nWhen you want to update the current version of your project, tag a commit with a [version tag](#version-tag-syntax). The most recent version tag found is taken as the current version.\n\n\u003cbr\u003e\n\n## Internal Behavior\n\n\u003cbr\u003e\n\n### Notes\n\n\u003cbr\u003e\n\nThis module:\n\n- Uses `GIT_FOUND` to check if git is present.\n- Uses `GIT_EXECUTABLE` to call git.\n\n\u003cbr\u003e\n\n### Quick flowchart\n\n\u003cbr\u003e\n\n![flowchart](flowchart.svg)\n\n\u003cbr\u003e\n\n### Details\n\n\u003cbr\u003e\n\nThe module won't start if git is not found.\n\\\nIf git is found, it queries the latest tag.\n\\\nIf no tag is found it checks the `.version` file.\n\\\nIf the latest tag does not contain the mandatory `major.minor.patch` pattern, the tag is not considered a valid version tag. It checks `.version` for the latest version cached.\n\\\nIf the tag is valid, it checks for a `-tweak.number` part. If not present/valid, it defaults it to `0.0`.\n\\\nFinally builds the output variables and cache them to `.version` in the project root directory.\n\\\n\\\nWhen checking `.version`, if it corrupted or it doesn't exist, sets the current major number to `1` and everything else at `0`. This is the last resort to pass CMake a valid version when calling `project`.\n\n\u003cbr\u003e\n\n### \u003cp id=\"version-tag-syntax\"\u003eValid version tag syntax\u003c/p\u003e\n\n\u003cbr\u003e\n\nGit version tag syntax: \n\n    [something]\u003cMajor\u003e.\u003cminor\u003e.\u003cpatch\u003e[-\u003ctweak_name\u003e[.\u003ctweak_number\u003e]]\n\n\u003cbr\u003e\n\n## Output Variables\n\n\u003cbr\u003e\n\nThe following variables will be set ( eg. complete latest git version tag: `v2.3.1-RC.7` ) :\n\n\u003cbr\u003e\n\n- `PROJECT_VERSION_STRING` \n    \u003e Version string without metadata. Directly corresponds to the latest version tag (`v2.3.1-RC.7`)\n\n- `PROJECT_VERSION_STRING_FULL`\n    \u003e Version string with added git metadata (`v2.3.1-RC.7+21.ef12c8`)\n\n- `PROJECT_VERSION` \n    \u003e Same as `PROJECT_VERSION_STRING`, without preceding letters (`2.3.1-RC.7`)\n\n- `PROJECT_VERSION_MAJOR` \n    \u003e Major version number (`2`)\n\n- `PROJECT_VERSION_MINOR`\n    \u003e Minor version number (`3`)\n\n- `PROJECT_VERSION_PATCH`\n    \u003e Patch version number (`1`)\n\n- `PROJECT_VERSION_MMP` \n    \u003e Simple `major.minor.patch` version string (`2.3.1`)\n\n- `PROJECT_VERSION_TWEAK_NAME`\n    \u003e Tweak version name (`RC`)\n\n- `PROJECT_VERSION_TWEAK_NUMBER`\n    \u003e Tweak version number : (`7`)\n\n- `PROJECT_VERSION_TWEAK_FULL`\n    \u003e Tweak version full string (`RC.7`)\n\n- `PROJECT_VERSION_COMMITS_AHEAD`\n    \u003e Number of commits ahead of last tag (`21`)\n\n- `PROJECT_VERSION_COMMIT_SHA`\n    \u003e Git SHA1 of the most recent commit (`ef12c8`)\n\n- `PROJECT_VERSION_CMAKE`\n    \u003e CMake compatible VERSION string, uses the `_TWEAK_NUMBER` as the build number (`2.3.1.7`)\n\n\u003cbr\u003e\n\n## Acknowledgements\n\n\u003cbr\u003e\n\nThis module was inspired by the public domain [cmake-git-semver](https://github.com/nunofachada/cmake-git-semver).\n\n\u003cbr\u003e\n\n[License](https://github.com/emanuelemessina/cmake-git-versioning/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femanuelemessina%2Fcmake-git-versioning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femanuelemessina%2Fcmake-git-versioning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femanuelemessina%2Fcmake-git-versioning/lists"}