From: Ali Maredia Date: Fri, 14 Oct 2016 18:02:17 +0000 (-0400) Subject: cmake: find GIT_VER variables if there is no .git dir X-Git-Tag: v11.0.2~1^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F11499%2Fhead;p=ceph.git cmake: find GIT_VER variables if there is no .git dir find CEPH_GIT_VER & CEPH_GIT_NICE_VER if there is no ceph/.git dir by parsing ceph/src/.git_version. scenario is for building from source tarballs generated by make-dist, since make-dist generates .git_version by running make_version, and then packs .git_version into the tarball. Signed-off-by: Ali Maredia --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index caab0a37cd37..34ca3c1a826f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -182,6 +182,13 @@ option(ENABLE_GIT_VERSION "build Ceph with git version string" ON) if(${ENABLE_GIT_VERSION}) get_git_head_revision(GIT_REFSPEC CEPH_GIT_VER) git_describe(CEPH_GIT_NICE_VER --always) + #if building from a source tarball via make-dist + if(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND") + message(STATUS "Ceph/.git directory not found, parsing ${CMAKE_CURRENT_SOURCE_DIR}/.git_version for CEPH_GIT_VER and CEPH_GIT_NICE_VER") + file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/.git_version CEPH_GIT_SHA_AND_TAG) + list(GET CEPH_GIT_SHA_AND_TAG 0 CEPH_GIT_VER) + list(GET CEPH_GIT_SHA_AND_TAG 1 CEPH_GIT_NICE_VER) + endif(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND") else(${ENABLE_GIT_VERSION}) set(CEPH_GIT_VER "no_version") set(CEPH_GIT_NICE_VER "Development")