mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-18 19:55:54 +00:00
add CMake funcion for determining current git rev
/GetGitHash.cmake has function get_git_hash that gives current git rev hash or "NO_GIT_COMMIT_HASH_DEFINED" if we are building out of git repo. It's used in /renderdoc/CMakeLists.txt
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
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)
|
||||
@@ -1,3 +1,5 @@
|
||||
include("${CMAKE_SOURCE_DIR}/GetGitHash.cmake")
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
set(RDOC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@@ -8,8 +10,7 @@ set(RDOC_INCLUDES
|
||||
set(RDOC_LIBRARIES)
|
||||
|
||||
# get git commit hash
|
||||
execute_process(COMMAND sh ${CMAKE_SOURCE_DIR}/calc_hash.sh
|
||||
OUTPUT_VARIABLE GIT_COMMIT_HASH)
|
||||
get_git_hash(GIT_COMMIT_HASH)
|
||||
string(STRIP ${GIT_COMMIT_HASH} GIT_COMMIT_HASH)
|
||||
list(APPEND RDOC_DEFINITIONS
|
||||
PRIVATE -DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
|
||||
|
||||
Reference in New Issue
Block a user