Keep git-describe.h in source tree

Temporary file goes to binary directory to avoid race between
simultanous builts.
develop
Pauli 2018-07-08 00:05:32 +03:00
parent 68d1dfa0da
commit fad9d58ac6
2 changed files with 7 additions and 7 deletions

@ -304,7 +304,7 @@ ELSE(WIN32)
ENDIF() ENDIF()
set(VERSION_SRCS DFHackVersion.cpp) set(VERSION_SRCS DFHackVersion.cpp)
set(VERSION_HDRS git-describe.h) set(VERSION_HDRS include/git-describe.h)
SET_SOURCE_FILES_PROPERTIES(${VERSION_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE) SET_SOURCE_FILES_PROPERTIES(${VERSION_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE)
@ -325,17 +325,19 @@ ENDIF()
# always re-run git-describe if cmake is re-run (e.g. if build ID or version changes) # always re-run git-describe if cmake is re-run (e.g. if build ID or version changes)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake) EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake)
target_include_directories(dfhack-version PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) ADD_CUSTOM_COMMAND(OUTPUT always_rebuild
COMMAND ${CMAKE_COMMAND} -E echo)
ADD_CUSTOM_COMMAND(OUTPUT always_rebuild ${CMAKE_CURRENT_BINARY_DIR}/git-describe.h ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/git-describe.h
COMMAND ${CMAKE_COMMAND} COMMAND ${CMAKE_COMMAND}
-D dfhack_SOURCE_DIR:STRING=${dfhack_SOURCE_DIR} -D dfhack_SOURCE_DIR:STRING=${dfhack_SOURCE_DIR}
-D git_describe_h:STRING=${CMAKE_CURRENT_BINARY_DIR}/git-describe.h -D git_describe_h:STRING=${CMAKE_CURRENT_SOURCE_DIR}/include/git-describe.h
-D git_describe_tmp_h:STRING=${CMAKE_CURRENT_BINARY_DIR}/git-describe.h
-D GIT_EXECUTABLE:STRING=${GIT_EXECUTABLE} -D GIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}
-D DFHACK_BUILD_ID:STRING=${DFHACK_BUILD_ID} -D DFHACK_BUILD_ID:STRING=${DFHACK_BUILD_ID}
-P ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake
COMMENT "Obtaining git commit information" COMMENT "Obtaining git commit information"
DEPENDS ${GIT_EXECUTABLE} DEPENDS ${GIT_EXECUTABLE} always_rebuild
VERBATIM VERBATIM
) )

@ -2,8 +2,6 @@ if(NOT EXISTS ${dfhack_SOURCE_DIR}/.git/index OR NOT EXISTS ${dfhack_SOURCE_DIR}
MESSAGE(FATAL_ERROR "Could not find git index file(s)") MESSAGE(FATAL_ERROR "Could not find git index file(s)")
endif() endif()
set(git_describe_tmp_h ${git_describe_h}.tmp)
if(EXISTS ${git_describe_tmp_h} AND EXISTS ${git_describe_h} AND if(EXISTS ${git_describe_tmp_h} AND EXISTS ${git_describe_h} AND
NOT(${dfhack_SOURCE_DIR}/.git/index IS_NEWER_THAN ${git_describe_tmp_h}) AND NOT(${dfhack_SOURCE_DIR}/.git/index IS_NEWER_THAN ${git_describe_tmp_h}) AND
NOT(${dfhack_SOURCE_DIR}/.git/modules/library/xml/index IS_NEWER_THAN ${git_describe_tmp_h}) AND NOT(${dfhack_SOURCE_DIR}/.git/modules/library/xml/index IS_NEWER_THAN ${git_describe_tmp_h}) AND