Coder Social home page Coder Social logo

versionfromgit.cmake's Introduction

VersionFromGit.cmake

DEPRECATED!

VersionFromGit is now part of munkei-cmake. This repository will not be updated.


Get a CMake project's version number from the latest Git tag.

This module uses Git to set the version number of a project (using git describe --tags). It is meant to be used in projects that are in a Git repository and have tags for each version. The version format must follow Semantic Versioning.

Builds in between tags get some added metadata; the current Git hash and optionally a timestamp.

Usage

There's just the one function; version_from_git().

version_from_git()

version_from_git(
  [GIT_EXECUTABLE command]
  [INCLUDE_HASH bool]
  [LOG bool]
  [TIMESTAMP format]
)

Gets the version information from Git.

Options

  • GIT_EXECUTABLE (optional)

    The name of, or full path to, Git. If not defined it will be found using find_package( Git ).

  • INCLUDE_HASH (optional)

    Whether to include the current Git hash as part of the metadata, if the current HEAD is not at a tag, à la git describe.

    Default: ON

  • LOG (optional)

    Whether to log the different parts obtained from Git.

    Default: OFF

  • TIMESTAMP (optional)

    A timestamp format (see CMake’s string( TIMESTAMP ... )), that, if defined, will be added as a part of the metadata.

Variables Set

  • GIT_TAG

    The current (latest) Git tag.

  • SEMVER

    The full semantic version, including identifiers and metadata.

  • VERSION

    The full three-part version, suitable for use with project().

  • VERSION_MAJOR

    The major version number.

  • VERSION_MINOR

    The minor version number.

  • VERSION_PATCH

    The patch version number.

Example

# Make sure CMake can find the file
list( APPEND CMAKE_MODULE_PATH /where/you/put/it/ )

# Load it
include( VersionFromGit )

# Use it
version_from_git(
  LOG       ON
  TIMESTAMP "%Y%m%d%H%M%S"
)

# Use `VERSION` for your project
project( MyProject
  VERSION ${VERSION}
)

# Use the full semantic version for things like package name, etc.
set( CPACK_PACKAGE_FILE_NAME MyProject-v${SEMVER} )

Requirements

  • CMake v3.0.0 or later
  • Git

License

The MIT License (MIT)

Copyright (c) 2015 Theo Willows

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

versionfromgit.cmake's People

Contributors

biffen avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.