Skip to content

Commit

Permalink
Use git describe to extract human readable revision info, re-added co…
Browse files Browse the repository at this point in the history
…de to generate cisstRevision.h using CMake custom command (was previously implemented for SVN)
  • Loading branch information
adeguet1 committed Jan 13, 2015
1 parent 1c6c28b commit 639ee10
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 10 deletions.
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ set (CISST_VERSION_MINOR "0")
set (CISST_VERSION_PATCH "2")
set (CISST_VERSION "${CISST_VERSION_MAJOR}.${CISST_VERSION_MINOR}.${CISST_VERSION_PATCH}")

# Generate cisstRevision.h
find_package (Git QUIET)
set (CISST_REVISION_HEADER_SRC "${cisst_SOURCE_DIR}/cisstRevision.h.in")
set (CISST_REVISION_HEADER "${cisst_BINARY_DIR}/include/cisstRevision.h")
# Script to be executed everytime
configure_file ("${cisst_SOURCE_DIR}/cmake/cisstGenerateRevision.cmake.in"
"${cisst_BINARY_DIR}/cisstGenerateRevision.cmake"
@ONLY)
add_custom_target (cisstRevision ALL
COMMAND ${CMAKE_COMMAND} -P "${cisst_BINARY_DIR}/cisstGenerateRevision.cmake"
COMMENT "Generating ${CISST_REVISION_HEADER} from ${CISST_REVISION_HEADER_SRC}"
SOURCES "${CISST_REVISION_HEADER_SRC}"
"${CISST_REVISION_HEADER}"
"${cisst_SOURCE_DIR}/cmake/cisstGenerateRevision.cmake.in"
"${cisst_BINARY_DIR}/cisstGenerateRevision.cmake")
set_property (TARGET cisstRevision PROPERTY FOLDER "cisstCommon")

# To compile examples within this project
set (CURRENT_PROJECT_IS_CISST ON)

Expand Down Expand Up @@ -101,6 +118,7 @@ configure_file ("${cisst_SOURCE_DIR}/cisstRevision.h.in"
"${cisst_BINARY_DIR}/include/cisstRevision.h")

# Install cisstRevision.h
set_source_files_properties ("${CISST_REVISION_HEADER}" GENERATED)
install (FILES "${cisst_BINARY_DIR}/include/cisstRevision.h"
DESTINATION include
COMPONENT cisstCommon)
Expand Down
6 changes: 2 additions & 4 deletions cisstCommon/code/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#
#
# (C) Copyright 2003-2013 Johns Hopkins University (JHU), All Rights
# Reserved.
# (C) Copyright 2003-2015 Johns Hopkins University (JHU), All Rights Reserved.
#
# --- begin cisst license - do not edit ---
#
Expand Down Expand Up @@ -109,5 +107,5 @@ cisst_add_library (
add_dependencies (cisstCommon cisstBuildType)

if (CISST_HAS_JSON)
add_dependencies (cisstCommon cisstJSONExternal)
add_dependencies (cisstCommon cisstRevision cisstJSONExternal)
endif (CISST_HAS_JSON)
3 changes: 1 addition & 2 deletions cisstConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
Author(s): Anton Deguet
Created on: 2004-02-18
(C) Copyright 2004-2014 Johns Hopkins University (JHU), All Rights
Reserved.
(C) Copyright 2004-2015 Johns Hopkins University (JHU), All Rights Reserved.
--- begin cisst license - do not edit ---
Expand Down
7 changes: 3 additions & 4 deletions cisstRevision.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */

/*
$Id$
Author(s): Anton Deguet
Created on: 2004-02-18
(C) Copyright 2011-2014 Johns Hopkins University (JHU), All Rights Reserved.
(C) Copyright 2011-2015 Johns Hopkins University (JHU), All Rights Reserved.
--- begin cisst license - do not edit ---
Expand All @@ -24,6 +22,7 @@ http://www.cisst.org/cisst/license.txt.
#ifndef _cisstRevision_h
#define _cisstRevision_h

#define CISST_FULL_REVISION "cisst ${CISST_VERSION}"
#define CISST_GIT_DESCRIBE "${CISST_GIT_DESCRIBE}"
#define CISST_FULL_REVISION "cisst ${CISST_VERSION} (git: ${CISST_GIT_DESCRIBE})"

#endif // _cisstRevision_h
40 changes: 40 additions & 0 deletions cmake/cisstGenerateRevision.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Cmake configuration file for the installed version of cisst
#
# Author(s): Anton Deguet
# Created on: 2011-11-08
#
# (C) Copyright 2011-2015 Johns Hopkins University (JHU), All Rights Reserved.
#
# --- begin cisst license - do not edit ---
#
# This software is provided "as is" under an open source license, with
# no warranty. The complete license can be found in license.txt and
# http://www.cisst.org/cisst/license.txt.
#
# --- end cisst license ---

set (CISST_VERSION_MAJOR "@CISST_VERSION_MAJOR@")
set (CISST_VERSION_MINOR "@CISST_VERSION_MINOR@")
set (CISST_VERSION "@CISST_VERSION@")

set (CISST_REVISION_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
set (CISST_REVISION_HEADER_SRC "@CISST_REVISION_HEADER_SRC@")
set (CISST_REVISION_HEADER "@CISST_REVISION_HEADER@")
set (GIT_FOUND @GIT_FOUND@)
set (GIT_EXECUTABLE "@GIT_EXECUTABLE@")

if (GIT_FOUND)
execute_process (COMMAND ${GIT_EXECUTABLE} describe
WORKING_DIRECTORY ${CISST_REVISION_DIR}
TIMEOUT 1
OUTPUT_VARIABLE CISST_GIT_DESCRIBE)
string (STRIP "${CISST_GIT_DESCRIBE}" CISST_GIT_DESCRIBE)
else (GIT_FOUND)
set (CISST_GIT_DESCRIBE "git-version-unavailable")
endif (GIT_FOUND)

message ("Found Git revision: ${CISST_GIT_DESCRIBE}")

configure_file ("${CISST_REVISION_HEADER_SRC}"
"${CISST_REVISION_HEADER}")

0 comments on commit 639ee10

Please sign in to comment.