Report commit hash in CMake development versions
For builds from Git repositories, add "-g<commit>" to the end of the version number. If the source tree is modified, append "-dirty". For builds from CVS checkouts, add "-cvs-<branch>".
This commit is contained in:
parent
e49b6eca4f
commit
0328379411
|
@ -344,6 +344,7 @@ SET(CMake_VERSION_PATCH 0)
|
|||
# Releases define a tweak level.
|
||||
IF(DEFINED CMake_VERSION_TWEAK)
|
||||
SET(CMake_VERSION_IS_RELEASE 1)
|
||||
SET(CMake_VERSION_SOURCE "")
|
||||
ELSE()
|
||||
SET(CMake_VERSION_IS_RELEASE 0)
|
||||
|
||||
|
@ -352,6 +353,8 @@ ELSE()
|
|||
SET(CMake_VERSION_TWEAK
|
||||
"${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}"
|
||||
)
|
||||
|
||||
INCLUDE(${CMake_SOURCE_DIR}/Source/CMakeVersionSource.cmake)
|
||||
ENDIF()
|
||||
|
||||
# Compute the full version string.
|
||||
|
@ -362,6 +365,9 @@ ENDIF()
|
|||
IF(CMake_VERSION_RC)
|
||||
SET(CMake_VERSION ${CMake_VERSION}-rc${CMake_VERSION_RC})
|
||||
ENDIF()
|
||||
IF(CMake_VERSION_SOURCE)
|
||||
SET(CMake_VERSION ${CMake_VERSION}-${CMake_VERSION_SOURCE})
|
||||
ENDIF()
|
||||
|
||||
# Include the standard Dart testing module
|
||||
ENABLE_TESTING()
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
# Try to identify the current development source version.
|
||||
set(CMake_VERSION_SOURCE "")
|
||||
if(EXISTS ${CMake_SOURCE_DIR}/.git/HEAD)
|
||||
find_program(GIT_EXECUTABLE NAMES git git.cmd)
|
||||
mark_as_advanced(GIT_EXECUTABLE)
|
||||
if(GIT_EXECUTABLE)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --verify -q --short=4 HEAD
|
||||
OUTPUT_VARIABLE head
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMake_SOURCE_DIR}
|
||||
)
|
||||
if(head)
|
||||
set(CMake_VERSION_SOURCE "g${head}")
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
|
||||
WORKING_DIRECTORY ${CMake_SOURCE_DIR}
|
||||
)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
|
||||
OUTPUT_VARIABLE dirty
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMake_SOURCE_DIR}
|
||||
)
|
||||
if(dirty)
|
||||
set(CMake_VERSION_SOURCE "${CMake_VERSION_SOURCE}-dirty")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
elseif(EXISTS ${CMake_SOURCE_DIR}/CVS/Repository)
|
||||
file(READ ${CMake_SOURCE_DIR}/CVS/Repository repo)
|
||||
set(branch "")
|
||||
if("${repo}" MATCHES "\\.git/")
|
||||
string(REGEX REPLACE ".*\\.git/([^\r\n]*).*" "-\\1" branch "${repo}")
|
||||
endif()
|
||||
set(CMake_VERSION_SOURCE "cvs${branch}")
|
||||
endif()
|
|
@ -259,12 +259,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
|
|||
,false, "Variables that Provide Information");
|
||||
cm->DefineProperty
|
||||
("CMAKE_VERSION", cmProperty::VARIABLE,
|
||||
"The full version of cmake in major.minor.patch[.tweak] format.",
|
||||
"The full version of cmake in major.minor.patch[.tweak[-id]] format.",
|
||||
"This specifies the full version of the CMake executable being run. "
|
||||
"This variable is defined by versions 2.6.3 and higher. "
|
||||
"See variables CMAKE_MAJOR_VERSION, CMAKE_MINOR_VERSION, "
|
||||
"CMAKE_PATCH_VERSION, and CMAKE_TWEAK_VERSION "
|
||||
"for individual version components.", false,
|
||||
"for individual version components. "
|
||||
"The [-id] component appears in non-release versions "
|
||||
"and may be arbitrary text.", false,
|
||||
"Variables that Provide Information");
|
||||
|
||||
cm->DefineProperty
|
||||
|
|
|
@ -232,4 +232,5 @@ TRY_COMPILE(EXPORTER_COMPILED
|
|||
MESSAGE(STATUS "Searching for export(PACKAGE) test project")
|
||||
SET(CMakeTestExportPackage_DIR "" CACHE FILEPATH
|
||||
"Wipe out find results for testing." FORCE)
|
||||
FIND_PACKAGE(CMakeTestExportPackage 1.${CMAKE_VERSION} EXACT REQUIRED)
|
||||
STRING(REGEX REPLACE "-.*$" "" version ${CMAKE_VERSION})
|
||||
FIND_PACKAGE(CMakeTestExportPackage 1.${version} EXACT REQUIRED)
|
||||
|
|
Loading…
Reference in New Issue