Skip to content

Instantly share code, notes, and snippets.

@Marqin
Created August 9, 2016 18:09
Show Gist options
  • Save Marqin/2c34dbcd68195e2ea4819510c6661db9 to your computer and use it in GitHub Desktop.
Save Marqin/2c34dbcd68195e2ea4819510c6661db9 to your computer and use it in GitHub Desktop.
function(get-git-hash _git-hash)
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
set(GIT_HASH "NO_GIT_COMMIT_HASH_DEFINED")
endif()
set(${_git-hash} "${GIT_HASH}" PARENT_SCOPE)
endfunction(get-git-hash)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment