2017-05-20 14:27:14 -06:00
|
|
|
if(NOT EXISTS ${dfhack_SOURCE_DIR}/.git/index OR NOT EXISTS ${dfhack_SOURCE_DIR}/.git/modules/library/xml/index)
|
|
|
|
MESSAGE(FATAL_ERROR "Could not find git index file(s)")
|
|
|
|
endif()
|
|
|
|
|
2018-06-25 06:25:13 -06:00
|
|
|
set(git_describe_tmp_h ${git_describe_h}.tmp)
|
2017-05-20 14:27:14 -06:00
|
|
|
|
2018-06-25 06:25:13 -06:00
|
|
|
if(EXISTS ${git_describe_tmp_h} AND EXISTS ${git_describe_h} AND
|
2017-05-20 14:27:14 -06:00
|
|
|
NOT(${dfhack_SOURCE_DIR}/.git/index IS_NEWER_THAN ${git_describe_tmp_h}) AND
|
2018-03-10 14:55:20 -07:00
|
|
|
NOT(${dfhack_SOURCE_DIR}/.git/modules/library/xml/index IS_NEWER_THAN ${git_describe_tmp_h}) AND
|
|
|
|
NOT(${dfhack_SOURCE_DIR}/library/git-describe.cmake IS_NEWER_THAN ${git_describe_tmp_h}))
|
2017-05-20 14:27:14 -06:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2017-04-23 16:16:00 -06:00
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=8 --long
|
2015-06-24 17:32:45 -06:00
|
|
|
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
|
|
|
|
OUTPUT_VARIABLE DFHACK_GIT_DESCRIPTION)
|
2015-08-06 15:30:51 -06:00
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
|
|
|
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
|
|
|
|
OUTPUT_VARIABLE DFHACK_GIT_COMMIT)
|
2017-04-23 16:16:00 -06:00
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=8 --exact-match
|
2015-10-17 13:35:40 -06:00
|
|
|
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
|
|
|
|
RESULT_VARIABLE DFHACK_GIT_TAGGED_RESULT
|
|
|
|
OUTPUT_QUIET ERROR_QUIET)
|
2016-02-01 08:30:53 -07:00
|
|
|
|
|
|
|
# Check library/xml for matching commits
|
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD:library/xml
|
|
|
|
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
|
|
|
|
OUTPUT_VARIABLE DFHACK_GIT_XML_EXPECTED_COMMIT)
|
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
|
|
|
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}/library/xml"
|
|
|
|
OUTPUT_VARIABLE DFHACK_GIT_XML_COMMIT)
|
|
|
|
|
|
|
|
file(WRITE ${git_describe_tmp_h} "")
|
|
|
|
|
|
|
|
macro(git_describe_definition var)
|
|
|
|
string(STRIP "${${var}}" GIT_DEF_VALUE)
|
|
|
|
file(APPEND ${git_describe_tmp_h} "#define ${var} \"${GIT_DEF_VALUE}\"\n")
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
git_describe_definition(DFHACK_GIT_DESCRIPTION)
|
|
|
|
git_describe_definition(DFHACK_GIT_COMMIT)
|
|
|
|
git_describe_definition(DFHACK_GIT_XML_EXPECTED_COMMIT)
|
|
|
|
git_describe_definition(DFHACK_GIT_XML_COMMIT)
|
2018-07-11 09:47:55 -06:00
|
|
|
git_describe_definition(DFHACK_BUILD_ID)
|
2015-10-17 13:35:40 -06:00
|
|
|
if(${DFHACK_GIT_TAGGED_RESULT} EQUAL 0)
|
2016-02-01 08:30:53 -07:00
|
|
|
file(APPEND ${git_describe_tmp_h} "#define DFHACK_GIT_TAGGED\n")
|
|
|
|
endif()
|
|
|
|
if(${DFHACK_GIT_XML_COMMIT} STREQUAL ${DFHACK_GIT_XML_EXPECTED_COMMIT})
|
|
|
|
file(APPEND ${git_describe_tmp_h} "#define DFHACK_GIT_XML_MATCH\n")
|
2015-10-17 13:35:40 -06:00
|
|
|
endif()
|
2015-06-24 17:32:45 -06:00
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
2016-02-01 08:30:53 -07:00
|
|
|
${git_describe_tmp_h} ${git_describe_h})
|