Douglas Gregor | 79f1dfa | 2013-03-25 23:14:19 +0000 | [diff] [blame] | 1 | # CMake project that writes Subversion revision information to a header. |
| 2 | # |
| 3 | # Input variables: |
| 4 | # FIRST_SOURCE_DIR - First source directory |
| 5 | # FIRST_REPOSITORY - The macro to define to the first revision number. |
| 6 | # SECOND_SOURCE_DIR - Second source directory |
| 7 | # SECOND_REPOSITORY - The macro to define to the second revision number. |
| 8 | # HEADER_FILE - The header file to write |
| 9 | include(FindSubversion) |
| 10 | if (Subversion_FOUND AND EXISTS "${FIRST_SOURCE_DIR}/.svn") |
| 11 | # Repository information for the first repository. |
| 12 | Subversion_WC_INFO(${FIRST_SOURCE_DIR} MY) |
| 13 | file(WRITE ${HEADER_FILE}.txt "#define ${FIRST_REPOSITORY} \"${MY_WC_REVISION}\"\n") |
| 14 | |
| 15 | # Repository information for the second repository. |
| 16 | if (EXISTS "${SECOND_SOURCE_DIR}/.svn") |
| 17 | Subversion_WC_INFO(${SECOND_SOURCE_DIR} MY) |
| 18 | file(APPEND ${HEADER_FILE}.txt |
| 19 | "#define ${SECOND_REPOSITORY} \"${MY_WC_REVISION}\"\n") |
| 20 | endif () |
| 21 | |
| 22 | # Copy the file only if it has changed. |
| 23 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different |
| 24 | ${HEADER_FILE}.txt ${HEADER_FILE}) |
| 25 | endif() |