From c72e661a9e81631825209264ccc84017198ec012 Mon Sep 17 00:00:00 2001 From: Soonho Kong Date: Fri, 17 Jul 2015 10:50:42 -0400 Subject: [PATCH] feat(CMakeLists.txt): add option USE_GITHASH (default:on) related issue: #733 --- src/CMakeLists.txt | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e3ca9d5fc..e0a2e990e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,6 +35,8 @@ option(CONSERVE_MEMORY "CONSERVE_MEMORY" OFF) option(INCLUDE_MSYS2_DLLS "INCLUDE_MSYS2_DLLS" OFF) # When ON we add lean binary dependency to standard and HOTT libraries option(LEAN_BIN_DEP "LEAN_BIN_DEP" ON) +# When ON we include githash in the version string +option(USE_GITHASH "GIT_HASH" ON) # Directory that include lean emacs mode dependecies set(EMACS_DEPENDENCIES "${CMAKE_SOURCE_DIR}/emacs/dependencies") @@ -266,17 +268,25 @@ find_package(PythonInterp REQUIRED) include_directories(${LEAN_SOURCE_DIR}) # Git HASH -include(GetGitRevisionDescription) -get_git_head_revision(GIT_REFSPEC GIT_SHA1) set(LEAN_PACKAGE_VERSION "NOT-FOUND") -if(${GIT_SHA1} MATCHES "GITDIR-NOTFOUND") - message(STATUS "Failed to read git_sha1") +if(USE_GITHASH) + include(GetGitRevisionDescription) + get_git_head_revision(GIT_REFSPEC GIT_SHA1) + if(${GIT_SHA1} MATCHES "GITDIR-NOTFOUND") + message(STATUS "Failed to read git_sha1") + if(EXISTS "${LEAN_SOURCE_DIR}/../bin/package_version") + file(STRINGS "${LEAN_SOURCE_DIR}/../bin/package_version" LEAN_PACKAGE_VERSION) + message(STATUS "Package version detected: ${LEAN_PACKAGE_VERSION}") + endif() + else() + message(STATUS "git commit sha1: ${GIT_SHA1}") + endif() +else() + set(GIT_SHA1 "GITDIR-NOTFOUND") if(EXISTS "${LEAN_SOURCE_DIR}/../bin/package_version") file(STRINGS "${LEAN_SOURCE_DIR}/../bin/package_version" LEAN_PACKAGE_VERSION) message(STATUS "Package version detected: ${LEAN_PACKAGE_VERSION}") endif() -else() - message(STATUS "git commit sha1: ${GIT_SHA1}") endif() configure_file("${LEAN_SOURCE_DIR}/githash.h.in" "${LEAN_BINARY_DIR}/githash.h")