Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Main Repositories
otb
Commits
209bf80b
Commit
209bf80b
authored
May 05, 2010
by
Emmanuel Christophe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: add mercurial versionning capabilities
parent
31464b5a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
4 deletions
+80
-4
CMake/FindMercurial.cmake
CMake/FindMercurial.cmake
+69
-0
CMakeLists.txt
CMakeLists.txt
+11
-4
No files found.
CMake/FindMercurial.cmake
0 → 100644
View file @
209bf80b
# - 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(Mercurial_FOUND)
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
)
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
)
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
(
NOT
${
Mercurial_hg_identify_result
}
EQUAL 0
)
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
(
NOT
${
Mercurial_hg_identify_result
}
EQUAL 0
)
# restore the previous LC_ALL
SET
(
ENV{LC_ALL}
${
_Mercurial_SAVED_LC_ALL
}
)
ENDMACRO
(
Mercurial_WC_IDENTIFY
)
ENDIF
(
Mercurial_HG_EXECUTABLE
)
IF
(
NOT Mercurial_FOUND
)
IF
(
NOT Mercurial_FIND_QUIETLY
)
MESSAGE
(
STATUS
"Mercurial was not found."
)
ELSE
(
NOT Mercurial_FIND_QUIETLY
)
IF
(
Mercurial_FIND_REQUIRED
)
MESSAGE
(
FATAL_ERROR
"Mercurial was not found."
)
ENDIF
(
Mercurial_FIND_REQUIRED
)
ENDIF
(
NOT Mercurial_FIND_QUIETLY
)
ENDIF
(
NOT Mercurial_FOUND
)
CMakeLists.txt
View file @
209bf80b
...
...
@@ -70,10 +70,17 @@ SET(OTB_VERSION_MAJOR "3")
SET
(
OTB_VERSION_MINOR
"2"
)
SET
(
OTB_VERSION_PATCH
"1"
)
# Version string should not include patch level. The major.minor is
# enough to distinguish available features of the toolkit.
SET
(
OTB_VERSION_STRING
"
${
OTB_VERSION_MAJOR
}
.
${
OTB_VERSION_MINOR
}
.
${
OTB_VERSION_PATCH
}
"
)
FIND_PACKAGE
(
Mercurial
)
IF
(
Mercurial_FOUND
)
Mercurial_WC_IDENTIFY
(
${
PROJECT_SOURCE_DIR
}
OTB
)
MESSAGE
(
"Mercurial version is
${
Mercurial_VERSION_HG
}
"
)
MESSAGE
(
"Repository revision is
${
Project_WC_REVISION
}
"
)
SET
(
OTB_VERSION_STRING
"
${
OTB_VERSION_MAJOR
}
.
${
OTB_VERSION_MINOR
}
.
${
OTB_VERSION_PATCH
}
.
${
Project_WC_REVISION
}
"
)
ELSE
(
Mercurial_FOUND
)
# Version string should not include patch level. The major.minor is
# enough to distinguish available features of the toolkit.
SET
(
OTB_VERSION_STRING
"
${
OTB_VERSION_MAJOR
}
.
${
OTB_VERSION_MINOR
}
.
${
OTB_VERSION_PATCH
}
"
)
ENDIF
(
Mercurial_FOUND
)
OPTION
(
BUILD_TESTING
"Build testing."
OFF
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment