[CMake] Addition to FindGit

Nicolas Desprès nicolas.despres at gmail.com
Sun Jun 5 07:30:30 EDT 2011


Hi,

That's a great idea.  I'd like to contribute some function too.  I
have rewritten a couple of them while working on project versioned by
Git.

Cheers,

-Nico

On Sun, Jun 5, 2011 at 11:02 AM, Quintus <sutniuq at gmx.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi there,
>
> I'm working on a git-versioned project that I'd like to display it's
> version number for development versions like this:
>
> 1.2.3-dev (commit abc1234 on devel, 12/4/10)
>
> CMake's FindGit module seems to be quite limited as it just gives me the
> path to git's executable file, leaving it on me to invoke the necessary
> EXECUTE_PROCESS() commands to find the current git branch and commit.
>
> After some googling, I found this project which added a function
> GIT_TREE_INFO() that provides information on the current commit:
> http://trac.evemu.org/browser/trunk/cmake/FindGit.cmake?rev=872
>
> Inspired by this, I wrote another function to get the current branch:
>
>  FUNCTION(GIT_BRANCH_INFO DIR PREFIX)
>    EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" branch --no-color
>      WORKING_DIRECTORY "${DIR}"
>      RESULT_VARIABLE GIT_RESULT
>      OUTPUT_VARIABLE GIT_FULL_BRANCH
>      ERROR_VARIABLE GIT_ERROR
>      OUTPUT_STRIP_TRAILING_WHITESPACE)
>
>    IF(NOT ${GIT_RESULT} EQUAL 0)
>      MESSAGE(SEND_ERROR "Command '${GIT_EXECUTABLE} branch --no-color'
> failed with following output:\n${GIT_ERROR}")
>    ENDIF(NOT ${GIT_RESULT} EQUAL 0)
>
>    STRING(REGEX MATCH "^\\* *([^ ]*)$"
>      GIT_ACTIVE_BRANCH
>      "${GIT_FULL_BRANCH}")
>
>    SET("${PREFIX}_BRANCH" "${CMAKE_MATCH_1}" PARENT_SCOPE)
>  ENDFUNCTION(GIT_BRANCH_INFO)
>
> Any chance to get this and the function from the evemu project into
> official CMake's FindGit.cmake? I'm not sure about their license, but
> the sourcecode seems to be licensed under LGPL -- if that's too
> restrictive I can write another function providing the same functionality.
>
> Marvin
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQEcBAEBAgAGBQJN60X/AAoJELh1XLHFkqhaHpsIAKiJOL1CBXE004WvthoOmJdO
> iCJFRus8RmGgRaNsQUlBBPiMuXJ0iFRBLK/zsKX4ubk6MXALxy4p4kp1a+bToE8k
> l/vEmgrxheva6Bx0Qao1hc/7tYDZXcNvG7ZRDEabSuWSWgsQQqEbqIKQ0sK5L1pw
> uBmXaj/IrJY2u5MO8liq0c/yUF/R39cLa7Hn9MSpf1eXy9QwBsX+HkedrbW0O4Rk
> pzFTX9hAre9iIfawghLVxV66hitN0letGG4nmRnROmPOjwjSYgxkhAoF+RVqRBoT
> anVCFjwOrPUfLXERRN9ELFDJjo7NTnOWQ3VFyr8rnY9TaAqnw+2mMftUhUexSFU=
> =n2I9
> -----END PGP SIGNATURE-----
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
Nicolas Desprès


More information about the CMake mailing list