mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 04:21:47 +00:00
cmake: reconfigure if git HEAD changes
This commit is contained in:
parent
5395194ed6
commit
cff0def2a4
1 changed files with 13 additions and 10 deletions
|
|
@ -172,22 +172,25 @@ add_subdirectory(src)
|
||||||
add_subdirectory(assets)
|
add_subdirectory(assets)
|
||||||
|
|
||||||
|
|
||||||
## config.h generation
|
|
||||||
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
|
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
|
||||||
include(GitUtilities)
|
include(GitUtilities)
|
||||||
git_latest_commit(SRB2_COMP_COMMIT "${CMAKE_SOURCE_DIR}")
|
|
||||||
git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}")
|
|
||||||
git_working_tree_dirty(SRB2_COMP_UNCOMMITTED "${CMAKE_SOURCE_DIR}")
|
|
||||||
set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}")
|
|
||||||
set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}")
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
|
|
||||||
|
|
||||||
|
|
||||||
if("${SRB2_SDL2_EXE_NAME}" STREQUAL "")
|
if("${SRB2_SDL2_EXE_NAME}" STREQUAL "")
|
||||||
|
# cause a reconfigure if the branch changes
|
||||||
|
get_git_dir(SRB2_GIT_DIR)
|
||||||
|
configure_file("${SRB2_GIT_DIR}/HEAD" HEAD COPYONLY)
|
||||||
|
|
||||||
|
git_current_branch(SRB2_GIT_REVISION)
|
||||||
|
|
||||||
|
if("${SRB2_GIT_REVISION}" STREQUAL "")
|
||||||
|
# use abbreviated commit hash if on detached HEAD
|
||||||
|
git_latest_commit(SRB2_GIT_REVISION)
|
||||||
|
endif()
|
||||||
|
|
||||||
list(APPEND EXE_NAME_PARTS "ringracers")
|
list(APPEND EXE_NAME_PARTS "ringracers")
|
||||||
|
|
||||||
if(NOT "${SRB2_GIT_BRANCH}" STREQUAL "master")
|
if(NOT "${SRB2_GIT_REVISION}" STREQUAL "master")
|
||||||
list(APPEND EXE_NAME_PARTS ${SRB2_GIT_BRANCH})
|
list(APPEND EXE_NAME_PARTS ${SRB2_GIT_REVISION})
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
list(APPEND EXE_NAME_PARTS ${SRB2_SDL2_EXE_NAME})
|
list(APPEND EXE_NAME_PARTS ${SRB2_SDL2_EXE_NAME})
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue