From 4bd57f7577fe845a671ada3900f53a809c953ce0 Mon Sep 17 00:00:00 2001 From: Minmin Gong Date: Sat, 8 Sep 2018 12:46:06 -0700 Subject: [PATCH] Add IGNORE_GIT_HASH. --- CMakeLists.txt | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1482fdfa..c53be5bba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,6 +110,11 @@ OPTION( INJECT_DEBUG_POSTFIX ON ) +OPTION ( IGNORE_GIT_HASH + "Don't call git to get the hash." + OFF +) + IF (IOS) IF (NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE "Release") @@ -153,23 +158,25 @@ SET( ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used # Enable C++1 globally set_property( GLOBAL PROPERTY CXX_STANDARD 11 ) -# Get the current working branch -EXECUTE_PROCESS( - COMMAND git rev-parse --abbrev-ref HEAD - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE GIT_BRANCH - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET -) +IF(NOT IGNORE_GIT_HASH) + # Get the current working branch + EXECUTE_PROCESS( + COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) -# Get the latest abbreviated commit hash of the working branch -EXECUTE_PROCESS( - COMMAND git log -1 --format=%h --no-show-signature - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE GIT_COMMIT_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET -) + # Get the latest abbreviated commit hash of the working branch + EXECUTE_PROCESS( + COMMAND git log -1 --format=%h --no-show-signature + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) +ENDIF() IF(NOT GIT_COMMIT_HASH) SET(GIT_COMMIT_HASH 0)