mirror of https://github.com/llvm/circt.git
[CMake] Run git describe from the source dir, fix out-of-tree builds (#3199)
Don't rely on build being same or underneath the source directory. Fixes #3175.
This commit is contained in:
parent
680420709b
commit
9f240a8329
|
@ -2,8 +2,9 @@
|
|||
# Input variables:
|
||||
# IN_FILE - An absolute path of Version.cpp.in
|
||||
# OUT_FILE - An absolute path of Version.cpp
|
||||
# RELEASE_PATTERN - A pattern to search release tags
|
||||
# RELEASE_PATTERN - A pattern to search release tags
|
||||
# DRY_RUN - If true, make the version unknown.
|
||||
# SOURCE_ROOT - Path to root directory of source
|
||||
|
||||
set(GIT_DESCRIBE_DEFAULT "unknown git version")
|
||||
if (DRY_RUN)
|
||||
|
@ -13,6 +14,7 @@ else ()
|
|||
find_package(Git QUIET)
|
||||
if (Git_FOUND)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty --tags --match ${RELEASE_PATTERN}
|
||||
WORKING_DIRECTORY "${SOURCE_ROOT}"
|
||||
RESULT_VARIABLE GIT_OUTPUT_RESULT
|
||||
OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
|
|
@ -32,12 +32,14 @@ if (CIRCT_RELEASE_TAG_ENABLED)
|
|||
DEPENDS "${CIRCT_GIT_LOGS_HEAD}" "${GEN_VERSION_SCRIPT}"
|
||||
COMMAND ${CMAKE_COMMAND} -DIN_FILE="${CMAKE_CURRENT_SOURCE_DIR}/Version.cpp.in"
|
||||
-DOUT_FILE="${VERSION_CPP}" -DRELEASE_PATTERN=${CIRCT_RELEASE_TAG}*
|
||||
-DDRY_RUN=OFF -P "${GEN_VERSION_SCRIPT}")
|
||||
-DDRY_RUN=OFF -DSOURCE_ROOT="${CMAKE_SOURCE_DIR}"
|
||||
-P "${GEN_VERSION_SCRIPT}")
|
||||
else ()
|
||||
# If the release tag generation is disabled, run the script only at the first
|
||||
# cmake configuration.
|
||||
add_custom_command(OUTPUT "${VERSION_CPP}"
|
||||
DEPENDS "${GEN_VERSION_SCRIPT}"
|
||||
COMMAND ${CMAKE_COMMAND} -DIN_FILE="${CMAKE_CURRENT_SOURCE_DIR}/Version.cpp.in"
|
||||
-DOUT_FILE="${VERSION_CPP}" -DDRY_RUN=ON -P "${GEN_VERSION_SCRIPT}")
|
||||
-DOUT_FILE="${VERSION_CPP}" -DDRY_RUN=ON -DSOURCE_ROOT="${CMAKE_SOURCE_DIR}"
|
||||
-P "${GEN_VERSION_SCRIPT}")
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue