Merge branch 'cmake-strings' into 'master'

CMake:Use commit hash and branch name.

Closes #37

See merge request STJr/SRB2!360
This commit is contained in:
Digiku 2018-12-03 22:58:23 -05:00
commit d507aa231e
3 changed files with 14 additions and 4 deletions

View file

@ -98,10 +98,10 @@ add_subdirectory(assets)
## config.h generation
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
include(GitUtilities)
git_describe(SRB2_GIT_DESCRIBE "${CMAKE_SOURCE_DIR}")
git_latest_commit(SRB2_COMP_COMMIT "${CMAKE_SOURCE_DIR}")
git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}")
set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}")
set(SRB2_COMP_REVISION "${SRB2_GIT_DESCRIBE}")
set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
##### PACKAGE CONFIGURATION #####

View file

@ -27,5 +27,17 @@ function(git_current_branch variable path)
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(${variable} "${output}" PARENT_SCOPE)
endfunction()
function(git_latest_commit variable path)
execute_process(COMMAND ${GIT_EXECUTABLE} "rev-parse" "--short" "HEAD"
WORKING_DIRECTORY "${path}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(${variable} "${output}" PARENT_SCOPE)
endfunction()

View file

@ -21,8 +21,6 @@
#define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}"
#define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}"
#define SRB2_GIT_DESCRIBE "${SRB2_GIT_DESCRIBE}"
#define SRB2_GIT_BRANCH "${SRB2_GIT_BRANCH}"
#define CMAKE_ASSETS_DIR "${CMAKE_SOURCE_DIR}/assets"