Skip to content

include current commit hash in build system #2

Closed

Description

@rigid

it would be nice if CMakeLists.txt could generate a "PACKAGE_BUILD" variable that holds the hash of the current commit, the build date or any other information to differ between different builds

Activity

  1. kaixiong commented on Apr 11, 2012

    @kaixiong
    Member

    I had wanted to implement this, but wasn't quite sure how to obtain the latest commit hash using git. (Now I know, it's git rev-parse HEAD).

    Apparently, lots of people use git describe, but that's limited to tags:
    http://stackoverflow.com/questions/1435953/how-can-i-pass-git-sha1-to-compiler-as-definition-using-cmake

  2. rigid commented on Apr 23, 2012

    @rigid
    MemberAuthor

    people from #git said you should use "git describe --always --dirty" so a "-dirty" is appended to mark that the source tree had local changes upon compile. I think that's enough to compare versions because changes can either be committed or stashed before compiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions