Regenerate components/version/version.hpp as HEAD moves on a git checkout
Pull request #416 introduced a common bug where version.hpp wouldn't be regenerated every build, poteantially leading to stale version data. This commit adds a custom build target, git-version, which updates version.hpp before the components library is built.openmw-35
parent
82ef145e79
commit
3024c67995
@ -0,0 +1,24 @@
|
||||
execute_process (
|
||||
COMMAND ${GIT_EXECUTABLE} rev-list --tags --max-count=1
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
RESULT_VARIABLE EXITCODE1
|
||||
OUTPUT_VARIABLE TAGHASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
execute_process (
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
RESULT_VARIABLE EXITCODE2
|
||||
OUTPUT_VARIABLE COMMITHASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
string (COMPARE EQUAL "${EXITCODE1}:${EXITCODE2}" "0:0" SUCCESS)
|
||||
if (SUCCESS)
|
||||
set(OPENMW_VERSION_COMMITHASH "${COMMITHASH}")
|
||||
set(OPENMW_VERSION_TAGHASH "${TAGHASH}")
|
||||
message(STATUS "OpenMW version ${OPENMW_VERSION}")
|
||||
else (SUCCESS)
|
||||
message(WARNING "Failed to get valid version information from Git")
|
||||
endif (SUCCESS)
|
||||
|
||||
configure_file(${VERSION_HPP_IN} ${VERSION_HPP})
|
Loading…
Reference in New Issue