2013-03-26 07:14:19 +08:00
|
|
|
# CMake project that writes Subversion revision information to a header.
|
|
|
|
#
|
|
|
|
# Input variables:
|
|
|
|
# FIRST_SOURCE_DIR - First source directory
|
2014-11-20 06:03:21 +08:00
|
|
|
# FIRST_NAME - The macro prefix for the first repository's info
|
|
|
|
# SECOND_SOURCE_DIR - Second source directory (opt)
|
|
|
|
# SECOND_NAME - The macro prefix for the second repository's info (opt)
|
2013-03-26 07:14:19 +08:00
|
|
|
# HEADER_FILE - The header file to write
|
2014-11-20 06:03:21 +08:00
|
|
|
#
|
|
|
|
# The output header will contain macros FIRST_REPOSITORY and FIRST_REVISION,
|
|
|
|
# and SECOND_REPOSITORY and SECOND_REVISION if requested, where "FIRST" and
|
|
|
|
# "SECOND" are substituted with the names specified in the input variables.
|
|
|
|
|
|
|
|
# Chop off cmake/modules/GetSVN.cmake
|
|
|
|
get_filename_component(LLVM_DIR "${CMAKE_SCRIPT_MODE_FILE}" PATH)
|
|
|
|
get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
|
|
|
|
get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
|
|
|
|
|
|
|
|
# Handle strange terminals
|
|
|
|
set(ENV{TERM} "dumb")
|
2013-09-17 05:38:01 +08:00
|
|
|
|
2014-11-20 06:03:21 +08:00
|
|
|
function(append_info name path)
|
|
|
|
execute_process(COMMAND "${LLVM_DIR}/utils/GetSourceVersion" "${path}"
|
|
|
|
OUTPUT_VARIABLE revision)
|
|
|
|
string(STRIP "${revision}" revision)
|
|
|
|
execute_process(COMMAND "${LLVM_DIR}/utils/GetRepositoryPath" "${path}"
|
|
|
|
OUTPUT_VARIABLE repository
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
string(STRIP "${repository}" repository)
|
|
|
|
file(APPEND "${HEADER_FILE}.txt"
|
|
|
|
"#define ${name}_REVISION \"${revision}\"\n")
|
|
|
|
file(APPEND "${HEADER_FILE}.txt"
|
|
|
|
"#define ${name}_REPOSITORY \"${repository}\"\n")
|
|
|
|
endfunction()
|
2013-03-26 07:14:19 +08:00
|
|
|
|
2014-11-20 06:03:21 +08:00
|
|
|
append_info(${FIRST_NAME} "${FIRST_SOURCE_DIR}")
|
|
|
|
if(DEFINED SECOND_SOURCE_DIR)
|
|
|
|
append_info(${SECOND_NAME} "${SECOND_SOURCE_DIR}")
|
2013-03-26 07:14:19 +08:00
|
|
|
endif()
|
2014-11-20 06:03:21 +08:00
|
|
|
|
|
|
|
# Copy the file only if it has changed.
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
"${HEADER_FILE}.txt" "${HEADER_FILE}")
|
|
|
|
file(REMOVE "${HEADER_FILE}.txt")
|
|
|
|
|