Commit 0b038448 authored by Julien Michel's avatar Julien Michel

CONF: Restauring mercurial revision check, which will enable again the *IsNighltyRevision tests

parent f228ad9c
# - Extract information from a mercurial working copy
# Example usage:
# find_package(Mercurial)
# if(Mercurial_FOUND)
# Mercurial_WC_IDENTIFY(${PROJECT_SOURCE_DIR} Project)
# message("Current revision is ${Project_WC_REVISION}")
# message("Mercurial version is ${Mercurial_VERSION_HG}")
# endif()
set(Mercurial_FOUND FALSE)
set(Mercurial_HG_FOUND FALSE)
find_program(Mercurial_HG_EXECUTABLE hg
DOC "mercurial command line client")
mark_as_advanced(Mercurial_HG_EXECUTABLE)
if(Mercurial_HG_EXECUTABLE)
set(Mercurial_HG_FOUND TRUE)
set(Mercurial_FOUND TRUE)
macro(Mercurial_WC_IDENTIFY dir prefix)
# the subversion commands should be executed with the C locale, otherwise
# the message (which are parsed) may be translated, Alex
set(_Mercurial_SAVED_LC_ALL "$ENV{LC_ALL}")
set(ENV{LC_ALL} C)
execute_process(COMMAND ${Mercurial_HG_EXECUTABLE} version
WORKING_DIRECTORY ${dir}
OUTPUT_VARIABLE Mercurial_VERSION_HG
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
execute_process(COMMAND ${Mercurial_HG_EXECUTABLE} identify ${dir}
OUTPUT_VARIABLE ${prefix}_WC_IDENTIFY
# ERROR_VARIABLE Mercurial_hg_identify_error
# RESULT_VARIABLE Mercurial_hg_identify_result
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
execute_process(COMMAND ${Mercurial_HG_EXECUTABLE} status -m ${dir}
OUTPUT_VARIABLE ${prefix}_WC_STATUS
# ERROR_VARIABLE Mercurial_hg_status_error
# RESULT_VARIABLE Mercurial_hg_status_result
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
if(NOT ${Mercurial_hg_identify_result} EQUAL 0)
message(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} identify ${dir}\" failed with output:\n${Mercurial_hg_identify_error}")
else()
string(REGEX REPLACE "^(.*\n)?Mercurial Distributed SCM [(]version ([.0-9]+).*"
"\\2" Mercurial_VERSION_HG "${Mercurial_VERSION_HG}")
string(REGEX REPLACE "^(.*\n)?([0-9a-f]+).*"
"\\2" ${prefix}_WC_REVISION "${${prefix}_WC_IDENTIFY}")
endif()
# restore the previous LC_ALL
set(ENV{LC_ALL} ${_Mercurial_SAVED_LC_ALL})
endmacro()
endif()
if(NOT Mercurial_FOUND)
if(NOT Mercurial_FIND_QUIETLY)
message(STATUS "Mercurial was not found.")
else()
if(Mercurial_FIND_REQUIRED)
message(FATAL_ERROR "Mercurial was not found.")
endif()
endif()
endif()
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)
if(OTB_DATA_ROOT)
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()
......@@ -48,6 +48,7 @@ if( CMAKE_HOST_WIN32 )
endif()
set(CMAKE_MODULE_PATH ${OTB_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH})
include (SourceStatus)
include(PreventInSourceBuilds)
include(PreventInBuildInstalls)
include(OTBModuleMacros)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment