git-describe: fail earlier if git fails to run or doesn't exist (#2061)

In cases where the cached `GIT_EXECUTABLE` does not exist, `git-describe.cmake`
would fail silently, resulting in a `git-describe.h` with missing definitions
that caused `DFHackVersion.cpp` to fail to compile.

This change produces a more descriptive error earlier in the build process.
develop
Alan 2022-03-30 17:49:18 -04:00 committed by GitHub
parent 4d5a157f4b
commit ec0941da2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

@ -1,10 +1,15 @@
# Generated from git-describe.cmake.in # Generated from git-describe.cmake.in
set(DFHACK_BUILD_ID "@DFHACK_BUILD_ID@") set(DFHACK_BUILD_ID "@DFHACK_BUILD_ID@")
if(NOT(EXISTS "${GIT_EXECUTABLE}"))
message(FATAL_ERROR "git-describe failed: could not find git at ${GIT_EXECUTABLE}")
endif()
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=8 --long execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=8 --long
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}" WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
OUTPUT_VARIABLE DFHACK_GIT_DESCRIPTION OUTPUT_VARIABLE DFHACK_GIT_DESCRIPTION
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE DFHACK_GIT_DESCRIPTION_RESULT)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}" WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
OUTPUT_VARIABLE DFHACK_GIT_COMMIT OUTPUT_VARIABLE DFHACK_GIT_COMMIT
@ -24,6 +29,10 @@ execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
OUTPUT_VARIABLE DFHACK_GIT_XML_COMMIT OUTPUT_VARIABLE DFHACK_GIT_XML_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT(${DFHACK_GIT_DESCRIPTION_RESULT} EQUAL 0))
message(FATAL_ERROR "git-describe failed: ${DFHACK_GIT_DESCRIPTION_RESULT}")
endif()
if(${DFHACK_GIT_TAGGED_RESULT} EQUAL 0) if(${DFHACK_GIT_TAGGED_RESULT} EQUAL 0)
set(DFHACK_GIT_TAGGED TRUE) set(DFHACK_GIT_TAGGED TRUE)
else() else()