# CMake script that writes version control information to a header.
#
# Input variables:
# NAMES - A list of names for each of the source directories.
# <NAME>_SOURCE_DIR - A path to source directory for each name in NAMES.
# HEADER_FILE - The header file to write
#
# The output header will contain macros <NAME>_REPOSITORY and <NAME>_REVISION,
# where "<NAME>" is substituted with the names specified in the input variables,
# for each of the <NAME>_SOURCE_DIR given.
list(APPEND CMAKE_MODULE_PATH
"${LLVM_CMAKE_DIR}")
# Handle strange terminals
get_source_info("${path}" revision repository)
file(APPEND "${HEADER_FILE}.tmp"
"#define ${name}_REVISION \"${revision}\"\n")
file(APPEND "${HEADER_FILE}.tmp"
"#undef ${name}_REVISION\n")
file(APPEND "${HEADER_FILE}.tmp"
"#define ${name}_REPOSITORY \"${repository}\"\n")
file(APPEND "${HEADER_FILE}.tmp"
"#undef ${name}_REPOSITORY\n")
if(NOT DEFINED ${name}_SOURCE_DIR
)
message(FATAL_ERROR "${name}_SOURCE_DIR is not defined")
append_info(${name} "${${name}_SOURCE_DIR}")
# Copy the file only if it has changed.
"${HEADER_FILE}.tmp" "${HEADER_FILE}")
file(REMOVE
"${HEADER_FILE}.tmp")