1# CMake project that writes Subversion revision information to a header. 2# 3# Input variables: 4# SRC - Source directory 5# HEADER_FILE - The header file to write 6# 7# The output header will contain macros FIRST_REPOSITORY and FIRST_REVISION, 8# and SECOND_REPOSITORY and SECOND_REVISION if requested, where "FIRST" and 9# "SECOND" are substituted with the names specified in the input variables. 10 11 12 13# Chop off cmake/modules/GetSVN.cmake 14get_filename_component(LLVM_DIR "${CMAKE_SCRIPT_MODE_FILE}" PATH) 15get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH) 16get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH) 17 18set(CMAKE_MODULE_PATH 19 ${CMAKE_MODULE_PATH} 20 "${LLVM_DIR}/cmake/modules") 21include(VersionFromVCS) 22 23# Handle strange terminals 24set(ENV{TERM} "dumb") 25 26function(append_info name path) 27 add_version_info_from_vcs(REVISION ${path}) 28 string(STRIP "${REVISION}" REVISION) 29 file(APPEND "${HEADER_FILE}.txt" 30 "#define ${name} \"${REVISION}\"\n") 31endfunction() 32 33append_info(${NAME} "${SOURCE_DIR}") 34 35# Copy the file only if it has changed. 36execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different 37 "${HEADER_FILE}.txt" "${HEADER_FILE}") 38file(REMOVE "${HEADER_FILE}.txt") 39 40