SourceStatus.cmake 2.59 KB
Newer Older
1
if(EXISTS "${PROJECT_SOURCE_DIR}/.hg")
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
find_package(Mercurial)
if(Mercurial_FOUND)
  message(STATUS "Repository status :")
  Mercurial_WC_IDENTIFY(${PROJECT_SOURCE_DIR} OTB)
  message(STATUS "  Mercurial version is ${Mercurial_VERSION_HG}")
  message(STATUS "  Repository revision is ${OTB_WC_REVISION}")
  set(OTB_WC_REVISION ${OTB_WC_REVISION} CACHE STRING "Repository version" FORCE)
  mark_as_advanced(OTB_WC_REVISION)
  if(OTB_WC_STATUS)
    message(STATUS "  Local file modifications:")
    string(REPLACE "\n" "\n--     " OTB_WC_STATUS_PRETTYPRINT "    ${OTB_WC_STATUS}")
    message(STATUS "${OTB_WC_STATUS_PRETTYPRINT}")
  else()
    message(STATUS "  No files modified locally")
  endif()
  string(REGEX REPLACE "\n" ";" OTB_WC_STATUS "${OTB_WC_STATUS}")
  set(OTB_WC_STATUS ${OTB_WC_STATUS} CACHE STRING "Repository status" FORCE)
  mark_as_advanced(OTB_WC_STATUS)
endif()
21 22 23 24 25
endif()

if(EXISTS "${PROJECT_SOURCE_DIR}/.git")
  find_package(Git)
  if(GIT_FOUND)
26
    execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%H
27
      WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
28
      OUTPUT_VARIABLE OTB_WC_REVISION
29 30 31 32 33 34
      OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
    execute_process(COMMAND ${GIT_EXECUTABLE} status -s
      WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
      OUTPUT_VARIABLE OTB_WC_STATUS
      OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
    message(STATUS "Repository status :")
35
    message(STATUS "  Repository revision is ${OTB_WC_REVISION}")
36 37 38 39 40 41 42 43 44
    if(OTB_WC_STATUS)
      message(STATUS "  Local file modifications:")
      string(REPLACE "\n" "\n--     " OTB_WC_STATUS_PRETTYPRINT "    ${OTB_WC_STATUS}")
      message(STATUS "${OTB_WC_STATUS_PRETTYPRINT}")
    else()
      message(STATUS "  No files modified locally")
    endif()
  endif()
endif()
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

if(OTB_DATA_ROOT)
  if(EXISTS "${OTB_DATA_ROOT}/.hg")
    if(NOT Mercurial_FOUND)
      find_package(Mercurial)
    endif()
    if(Mercurial_FOUND)
      Mercurial_WC_IDENTIFY(${OTB_DATA_ROOT} OTB_DATA)
      set(OTB_DATA_WC_REVISION ${OTB_DATA_WC_REVISION} CACHE STRING "Repository version" FORCE)
      mark_as_advanced(OTB_DATA_WC_REVISION)
    endif()
  endif()
  
  if(EXISTS "${OTB_DATA_ROOT}/.git")
    if(NOT GIT_FOUND)
      find_package(Git)
    endif()
    if(GIT_FOUND)
      execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%H
        WORKING_DIRECTORY ${OTB_DATA_ROOT}
        OUTPUT_VARIABLE OTB_DATA_WC_REVISION
        OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
      set(OTB_DATA_WC_REVISION ${OTB_DATA_WC_REVISION} CACHE STRING "Repository version" FORCE)
      mark_as_advanced(OTB_DATA_WC_REVISION)
    endif()
  endif()
endif()