1 # CMake project that writes Subversion revision information to a header.
4 # SRC - Source directory
5 # HEADER_FILE - The header file to write
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.
13 # Chop off cmake/modules/GetSVN.cmake
14 get_filename_component(LLVM_DIR "${CMAKE_SCRIPT_MODE_FILE}" PATH)
15 get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
16 get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
20 "${LLVM_DIR}/cmake/modules")
21 include(VersionFromVCS)
23 # Handle strange terminals
26 function(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")
33 append_info(${NAME} "${SOURCE_DIR}")
35 # Copy the file only if it has changed.
36 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
37 "${HEADER_FILE}.txt" "${HEADER_FILE}")
38 file(REMOVE "${HEADER_FILE}.txt")